The Most Active and Friendliest
Affiliate Marketing Community Online!

“AdsEmpire”/  Direct Affiliate

How to implement server side script in my domain - S2S tracking

Rajeshsaravanan

New Member
How to implement server side script in my domain for Server to Server Conversion tracking (Traffic Source - Facebook).
Technical perspective from Thrive traffic source postback URL data need to transfer it to Facebook Conversion API through My domain.
 
Caution: This is just an AI example. You will have to modify it before it will function properly.

You need to relay the postback from Thrive to a new post to Facebook using their endpoint and your credentials with

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://graph.facebook.com/v13.0/{$pixelId}/events");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(array(
'data' => json_encode(array($data)),
'access_token' => $accessToken

)));
start here: Conversions API | Facebook
more specifically: Using the API - Conversions API - Documentation - Meta for Developers
Or you could hire an experienced Facebook Developer


1722164820479.png

PHP:
<?php
// Receive postback data from Thrive
$thriveData = $_GET; // Assuming data is sent via GET parameters

// Extract relevant information
$eventName = $thriveData['event_name'];
$value = $thriveData['value'];
$currency = $thriveData['currency'];

// Prepare data for Facebook
$data = array(
    'event_name' => $eventName,
    'event_time' => time(),
    'user_data' => array(
        'client_ip_address' => $_SERVER['REMOTE_ADDR'],
        'client_user_agent' => $_SERVER['HTTP_USER_AGENT']
    ),
    'custom_data' => array(
        'value' => $value,
        'currency' => $currency
    )
);

// Send data to Facebook Conversion API

$accessToken = 'YOUR_FACEBOOK_ACCESS_TOKEN';
$pixelId = 'YOUR_PIXEL_ID';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://graph.facebook.com/v13.0/{$pixelId}/events");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(array(
    'data' => json_encode(array($data)),
    'access_token' => $accessToken
)));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
curl_close($ch);

echo $response;
?>
1722164870096.png
 
Last edited:
MI
Back