Passing Transaction Data for Conversion Pixels

We have a number of places where PayKickstart passes data to the vendor or allow you to add tracking scripts.

In terms of passing data, note that in both the thank you page and the IPN, the data is always sent as a POST (like a form submit), and is never passed through the URL (i.e. a “GET”). There’s a number of good reasons for this, including that passing data as GET variables to pages we do not control often breaks the page we’re redirecting to (e.g. many vendors use page builders and many of those expect specific URL parameters – if we send them others their system often just returns an error instead of loading the page).

For 3rd party conversion scripts, we have an “intermediary” page which loads directly after each purchase. This is the page where you can add conversion scripts, such as the one you have for Facebook – look in the “integrations” section of your Campaigns >> Edit Product, there is a place you can add the script to the header of the page and in the body of the page.

Go to Section 3(integrations)

Some purchase data is available to be used by your script on this page, so if you add your script to that page you can grab the available data and use inside your script.

Following is the list of available data as Javascript variables:

Payment Processor: _pk_obj.payment_processor
Order Total Amount: _pk_obj.amount
Buyer First Name: _pk_obj.buyer_first_name
Buyer Last Name: _pk_obj.buyer_last_name
Buyer Email: _pk_obj.buyer_email
Transaction ID _pk_obj.transaction_id
Invoice ID: _pk_obj.invoice_id
Transaction Time: _pk_obj.transaction_time
Product ID: _pk_obj.product_id
Product Name: _pk_obj.product_name
Campaign ID: _pk_obj.campaign_id
Campaign Name: _pk_obj.campaign_name
Custom Fields: _pk_obj.custom_{name}
replace {name} with the custom field’s name
Customer ID: _pk_obj.customer_id
Funnel ID: _pk_obj_funnel_id
Funnel Name: _pk_obj_funnel_name

For 3rd party JS scripts you would add these variables inside the <script> </script> tags.

The below fields will only be present in the case where an order bump is enabled and was also purchased. The fields will be available as part of the parent product’s data on the intermediate page (add conversion pixels to the parent product to track the bump).

Order Bump Amount: _pk_obj.bump_amount
Order Bump Transaction ID _pk_obj.bump_transaction_id
Order Bump Product ID: _pk_obj.bump_product_id
Order Bump Product Name: _pk_obj.bump_product_name
Order Bump Campaign ID: _pk_obj.bump_campaign_id
Order Bump Campaign Name: _pk_obj.bump_campaign_name

For 3rd party JS scripts you would add these variables inside the <script> </script> tags.

Passing Conversion Data to Facebook

If you would like to pass the conversion data to your Facebook pixel you will need to add this line of code to your Facebook tracking pixel.

fbq('track', 'Purchase', {value: _pk_obj.amount, currency:'USD'});

Note: Replace the correct variables with the data you would like to pass to Facebook.

More information on conversion tracking: https://developers.facebook.com/docs/facebook-pixel/pixel-with-ads/conversion-tracking

Example of Fb Tracking script with added PK Conversion Variables:

<!-- Facebook Pixel Code -->
<script>
!function(f,b,e,v,n,t,s)
{if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};
if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];
s.parentNode.insertBefore(t,s)}(window, document,'script',
'https://connect.facebook.net/en_US/fbevents.js');
fbq('init', '2335f775287886610');
fbq('track', 'PageView');
fbq('track', 'ViewContent');
fbq('track', 'Purchase', {value: _pk_obj.amount, currency:'USD'});
</script>
<!-- End Facebook Pixel Code -->



NOTE: If you would like to test the conversion script firing, add the following script code to the bottom of the "body" section. This will cause the intermediate page to not redirect to the next page. Once the page is loaded, you can inspect it or view its source(view page source) as needed.

<script>window.onload=function() { return true; };</script>

You would want to remove this test code snippet after testing.


Some vendors may need to add a delay to the script for testing purposes, or to ensure certain script have enough time to execute. You can add this script, which will add a 5 second delay to the intermediate page, allowing a little extra time before the intermediate page fires. You can change the delay by replacing the 5000 with a delay of your choice, in milliseconds.

<script>
window.onload = function() { return true; }
setTimeout(function(){
var url = new URL(window.location);
window.top.location = atob(url.searchParams.get("url"));
}, 5000);
</script>

Related Articles