Clickbank Integration Postback
Updated over a week ago

Tracking offers obtained from Clickbank may be a bit challenging and isn’t easy to figure out, unless you know a few tricks. Luckily, we have prepared a solution for you that will allow you to track conversions with help of PeerClick. In this guide, we will show you exactly how to do this.

First of all, you need to understand that Clickbank will only call a Postback to a secure domain. It can be absolutely any domain you own, as long as it starts with https://

Step 1. Create and upload a PHP file to your server

Below we have attached a PHP file specially for PeerClick users. It contains all the tracking information used by Clickbank and needs to be uploaded to your website.

Here’s the to the file:

<?php 

// This script only reports initial sales and upsells.
// If you were using Funnel Flux instead, then rebills and refunds // would also be tracked automatically as Funnel Flux is fully integrated with Clickbank.
//
// Instructions: You will edit the 4 parameters defined
// in the "SETTINGS TO EDIT" section below.
//
// 1/ Replace the value of $postbackURL by the postback URL given to you by
// your tracker BUT in that URL keep only the part that is before the ?
//
// 2/ Replace the value of $cidParameterName by the name of the click-id
// parameter (example: "cid" for PeerClick)
//
// 3/ Replace the value of $payoutParameterName by the name of the parameter
// that allows you to track your commissions for a conversion (example: "payout" for PeerClick)
//
// 4/ Replace the value of $transactionParameterName by the name of the parameter
// that allows you to track upsells (example: "txid" for PeerClick)
//
// Only $postbackURL and $cidParameterName are mandatory.
// If you do not want or can't fill in the other two, then make them empty like this:
// $payoutParameterName = ""
// $transactionParameterName = ""
//-----------------------------------------------------
// SETTINGS TO EDIT
//-----------------------------------------------------

$postbackURL = "https://pstb.peerclicktrk.com/postback?userid=XXXX&cid=REPLACE&payout=OPTIONAL&txid=OPTIONAL"; $cidParameterName = "cid";
$payoutParameterName = "payout";
$transactionParameterName = "txid";

//-----------------------------------------------------
//-----------------------------------------------------
// DO NOT TOUCH ANYTHING BELOW
//-----------------------------------------------------

$tid = filter_input(INPUT_GET, "trackingCodes");
$payout = filter_input(INPUT_GET, "affiliateCommission");
$txid = filter_input(INPUT_GET, "receipt");
$aParams = array();
if( $tid !== null && !empty($cidParameterName) ) $aParams[$cidParameterName] = $tid;
if( $payout !== null && !empty($payoutParameterName) ) $aParams[$payoutParameterName] = $payout;
if( $txid !== null && !empty($transactionParameterName) ) $aParams[$transactionParameterName] = $txid;
$aParts = explode("?", trim($postbackURL));
$finalPostbackURL = $aParts[0]."?".http_build_query($aParams);
if( $finalPostbackURL ) { $ch = curl_init($finalPostbackURL); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_exec($ch);
curl_close($ch);
}

Grab the full URL of where file can be found on your website. It will look like:

Step 2. Add your Pixel to Clickbank

Open your Clickbank account and go to Settings. Choose the My site tab.

Scroll down to the Integrated sales reporting and click Add tracking code. Here you need to choose Tracking Pixel: Order Confirmation (Receipt).

Choose to track sales as Affiliate and input the URL of your tracking pixel you’ve obtained in Step 1.

Step 3. Modify the link for your Clickbank offers

In order to enable tracking, you need to add tracking macros to your offer URL obtained from Clickbank. If you wish to use PeerClick, the correct parameter will be {clickid}.

The correct offer URL should look like this:

Step 4. Create an offer in PeerClick

Now you’re all set! Enjoy tracking your Clickbank offers in as little as 4 steps:

  • Grab our PHP file and upload it to your website

  • Add the link to your PHP file to your Clickbank account

  • Modify offer URL

  • Create an offer in PeerClick

Then upload that file on your server, in a way that you can access it via the URL mentioned in Clickbank at a previous step. In our example it was https://yourdomain.com/vitavee-cb.php

Go back to Clickbank, and activate your tracking pixel:

Did this answer your question?