![]() |
|
pass_subid.js
variants. For the most up-to-date approach, read this article:pass_subids.js
works is pretty simple. When the page is loaded, the JavaScript code will search for all occurrences of the Sub-ID tokens [s1]
through [s5]
in the <body>
section of the page and replace them with the corresponding s1
through s5
query string values passed to the page.1. |
Caution: If you insert this Sub-ID JavaScript code at the top of the <body> section it won’t work correctly and may also cause your page to flicker or flash momentarily. To work correctly, this JavaScript code must be inserted as close to the final </body> tag as possible.The technical reason why you need to place the JavaScript at the bottom of the page is that the code will run as soon as the web browser encounters it, causing the rest of the page to stop loading. This means, for example, that if you place the JavaScript code at the very start of your page, right after the opening <body> tag, the code will run before any of the HTML coming after it has loaded and therefore won’t update any [s1] tokens that come after it. In short, this means that the JavaScript code must come after any [s1] tokens in your HTML that you want to have replaced. The easiest way to ensure that the code will do what you expect is to simply insert it at the very end of your page, right before the </body> tag. |
2. | The next step is to use the Sub-ID tokens [s1] , [s2] , [s3] , [s4] and [s5] in the <body> section of your page wherever you want the corresponding s1 through s5 query string values to be inserted.For example, if you want to add the value of the s1 query string parameter to the end of your ClickBank affiliate link, you’d do it like this:https://xxx.yyy.hop.clickbank.net/?tid=[s1] If you want to pass any of the s1 through 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/[s1]/[s2]/[s3] Caution: You cannot use the [s1] through [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. For more information, see the caution at the end of this page. |
3. | The [s1] through [s5] tokens won’t work between <script> …</script> tags. If you need to use any of the s1 through s5 query string values in existing JavaScript code, you must use the JavaScript variables qsubids.s1 , qsubids.s2 etc. to “build” the URL.For example, instead of writing this link in your JavaScript code... window.open("https://www.site.com?s1=[s1]&s2=[s2]"); // Incorrect ... which won’t work, you would need to code it this way: window.open("https://www.site.com?s1=" + qsubids.s1 + "&s2=" + qsubids.s2); Similarly, if you want to pass query string values to a ClickMagick tracking link in JavaScript code, you can’t write... window.open("https://www.clkmg.com/[USERNAME]/somelink/[s1]/[s2]"); // Incorrect ... which also won’t work. Instead, you would have to code it like this: window.open("https://www.clkmg.com/[USERNAME]/somelink/" + qsubids.s1 + "/" + qsubids.s2); |
4. | Once you have your page set up, you can link to it by passing your Sub-ID values to your page by adding a query string to your link like this:https://www.site.com/page.html?s1=val1&s2=val2&s3=val3&s4=val4&s5=val5 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. |
5. | If you need to pass Sub-IDs to multiple pages through a funnel, just repeat this process for every applicable page and then chain them all together. Just remember that if you’re chaining two pages together through a tracking link rather than by a direct link, the Primary URL of the tracking link should pass on the Sub-ID values it gets by using the same [s1] -[s5] tokens:Primary URL: https://www.site.com/nextpage.html?s1=[s1]&s2=[s2]&s3=... |
<form action="...">
...
<input type="hidden" name="thankyou_url" value="https://www.site.com/thankyou.html">
...
</form>
[s1]
—[s5]
tokens to the Thank You page URL. So, if you were passing the click ID through the s1
query string variable, you would create (or add) the s1
variable to the URL:<input type="hidden" name="thankyou_url" value="https://www.site.com/thankyou.html?s1=[s1]">
s1
value that was passed to your opt-in page, and pass it right along to your Thank You page after the visitor’s email address has been captured.[s1]
-[s5]
tokens in the Thank You page URLs of their forms. If you run into this restriction, simply enter a fake URL for the Thank You page URL, then once you generate the autoresponder HTML for the form, simply replace the fake URL in the HTML code with the actual Thank You page URL that contains the [s1]
-[s5]
tokens.<input type="hidden" name="custom1" value="[s1]">
<input type="hidden" name="custom2" value="[s2]">
<head>
…</head>
section of your page is unpredictable, which means you can’t use the [s1]
-[s5]
tokens anywhere in your page header. It is especially important to remember that you cannot use these tokens in a “meta refresh” tag and expect them to work.// This meta refresh will not work reliably...
<meta http-equiv="refresh" content="3; url=https://mylink.com?s1=[s1]">