Thank you page and custom script

ivan_cazzol
Shopify Partner
7 0 1

Hello everybody,
I got a good offer to increase my market share from a social marketing company. They are asking me to insert a tracking script in my "thank you page" in order to monitoring sales coming from their job. I've inserted the script inside Additional content and scripts field located under Settings / Checkout.
Now I need to modify 3 parameters inside the script with the name of my shopify variables  

I had insert some comments about the customization.

<script type="text/javascript">
document.write(unescape("%3Cscript id=%27pap_x2s6df8d%27 src=%27" + (("https:" == document.location.protocol) ? "https://" : "http://") + "xxxxxxxx/scripts/trackjs.js%27 type=%27text/javascript%27%3E%3C/script%3E")); 
 </script> <script type="text/javascript">
PostAffTracker.setAccountId('default1');
var sale = PostAffTracker.createSale();

// Customize the following parameters using your custom variables  

//replace 120.50 with the name of your TotalCost variable.   
sale.setTotalCost('120.50');

//replace ORD_12345XYZ with the name of your OrderID variable.   
sale.setOrderID('ORD_12345XYZ');

//replace "test product" with the name of your ProductID variable.
sale.setProductID('test product');

// End customization


sale.setCampaignID('xxxxxx');
PostAffTracker.register();
</script>

 

Where can I find the name of those variables ??
Thank you very much for your support.

 

0 Likes
Mircea_Piturca
Shopify Partner
1489 42 316

sale.setTotalCost('{{ checkout.total_price }}');

sale.setOrderID('{{ checkout.order_id }}');

not sure on this one, this is just for one product, you may need a loop.

sale.setProductID('{{ checkout.line_items[0].product_id }}')

Here is the checkout object: https://docs.shopify.com/themes/liquid-documentation/objects/checkout

 

 

 

 

 

Finally—Add variant descriptions to your products
0 Likes
CH_Digital
Shopify Partner
27 0 5

How did you ensure this only showed up on the "Thank You" page? I need to do the same thing, but the Additional Scripts box goes to all order status pages, and is giving false data back to the conversion tracking.

0 Likes
CH_Digital
Shopify Partner
27 0 5

Thanks. I realize that the thank you page / order status page has changed, but this was what I was looking for. A way to ensure it only gets hit once, on first visit.  Should do the trick!

 

Chris

0 Likes
Petscentric
New Member
2 0 0

Hi,

 

Even I want to insert a script on my Thank you page. The link shared on this thread is not working. Please help. 

0 Likes