Knowledge Base         


How do I pass data to my affiliate network?


Sometimes you might want to pass more than just a click ID to your affiliate network.

ClickMagick’s cmtools.js JavaScript code allows you to store and pass up to 5 Sub-ID values (cm_s1 through cm_s5) all the way from the first page of your funnel to the last page.

Because these Sub-ID values are stored in browser cookies, you only need to add the cmtools.js code to the first and last pages of your funnel.

This article talks about “query strings” a lot. so if you’re a unsure about “query strings”, you should read the following article to get comfortable with them first:
 
What is a “query string”?
 

Now here’s how you can pass Sub-ID values throughout your funnel:
 
1.   
Add the following JavaScript code in the “head” or “body” section of the first and last pages of your funnel to load cmtools.js.

 

This code will save the cm_s1 through cm_s5 query string values in cookies with the same name.
 
 
Note: If you don’t have a “last page” because you’re sending people from your email submit page straight to an affiliate offer, you might need to create a bridge page. This article explains how to do just that:

How to pass data through my email submit page?

  
2.    Once you have your pages set up, you can pass your Sub-ID values cm_s1 through cm_s5 to the first page of your funnel by adding a query string to the Primary URL of your tracking link like this:

https://www.site-page1.com/page.html?cm_s1=value1&cm_s2=value2&...&cm_s5=value5

All of the Sub-IDs are optional, so you can omit any name=value pair or just leave the value blank for any Sub-ID you’re not using.

    
3.    If you want to pass the values from Page 1 of your website to Page 2, you’d pass them like this:

https://www.site-page2.com/page.html?cm_s1=[cm_s1]&cm_s2=[cm_s2]&...&cm_s5=[cm_s5]

The cmtools.js code you added to Page 1 will convert the [cm_s1] through [cm_s5] tokens to their values before the link is used.

If you want to pass any of the cm_s1 through cm_s5 query string values to a ClickMagick tracking link on the page, simply insert the tokens as Sub-IDs for the link:

https://www.clkmg.com/[USERNAME]/somelink/[cm_s1]/[cm_s2]/…/[cm_s5]

As an example, let’s assume you have a ClickBank affiliate link. If you want to add the value of the cm_s1 query string parameter to the end of your ClickBank affiliate link in order to pass a click ID, you’d do it like this (assuming you passed the click ID in the Sub-ID 1 slot):

https://xxx.yyy.hop.clickbank.net/?tid=[cm_s1]
 

What if I’m using JavaScript?
 
 
Caution: You cannot use the [cm_s1] through [cm_s5] tokens in the <head> section of a page. Replacing text in the <head> section is undefined behavior in HTML and does not work in all browsers.

    
That’s it! You should now be able to pass your Sub-ID values throughout your funnel, no matter how many pages it has.  
 
 
Note: For this cookie approach to work, the page where the URL values are stored and the page where the Sub-ID tokens are replaced must be on the same web domain, which will be true in almost all cases.

If you need to switch domains partway through your funnel, add the JavaScript code to the last page of the first domain and use it to replace Sub-ID tokens in the URL that leads to the page on the second domain. Just add the same JavaScript code on that first page of the second domain to store the Sub-ID values in cookies on the second domain.
 
 
Tip: For a detailed discussion on how the cmtools.js code actually works, read this:
 
How does the JavaScript cmtools.js code work?


Article 99 Last updated: 06/26/2020 12:27:50 PM
https://www.clickmagick.com/kb/?article=99