Knowledge Base      

Where can I find information about pass_subids.js?

Note: This article describes an older, less flexible approach to passing sub-IDs through funnel pages. DO NOT USE THIS ANYMORE. It is here only for reference by people who are still using any of the pass_subid.js variants. For the most up-to-date approach, read this article:
Can I pass data to my affiliate links or autoresponder?

Where can I find information about pass_subids.js?

The way 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.

This lets you set values in links and hidden form fields without actually knowing what those values will be ahead of time. Just insert the tokens as placeholders and the magick will happen.

Query strings are a pretty important part of passing data to affiliate links, so if you don’t know what a query string is and how you pass data using them, you should study the following article until you feel totally comfortable with the topic:
What is a “query string”?

Finally, for each page that you want to pass data through, simply follow these steps:
Add the following Sub-ID code to the very end of your page, just before the closing </body> tag. (Some Page Builders call this the “footer” section, not to be confused with the <footer></footer> tags.)

<script src='//'></script>

This is the code that dynamically replaces the [s1] through [s5] tokens in the <body> section of your page with the actual values of the s1 through s5 query string values passed to the page.

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:[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:[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..."[s1]&s2=[s2]");   // Incorrect

... which won’t work, you would need to code it this way:"" + 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..."[USERNAME]/somelink/[s1]/[s2]");  // Incorrect

... which also won’t work. Instead, you would have to code it like this:"[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:

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:[s1]&s2=[s2]&s3=... 

Demo: Here’s a demo page with the JavaScript installed. Play with the query string parameters so you can see the code in action …

Sub-ID Demo Page

Passing Data to your Autoresponder

To pass one or more Sub-IDs (including the click ID) through an email opt-in form, the best way is to pass the value through the Thank You page URL in the HTML generated by your autoresponder form editor.

Most autoresponders today have editors where you can design the opt-in form for your email opt-in page.

As you edit your form, look for a “Thank You” page setting or “Success” page URL setting and point it to the next page in your funnel.

Once you’ve created the opt-in form, you’re generally asked to “publish” it. You’re typically given two formats to publish your form in: an HTML version and a JavaScript version.

We’re hoping to find the “Thank You” page or “Success” page URL somewhere in the HTML or JavaScript code. If we find that, then passing sub-IDs (and the click ID) is super easy.
For instance, suppose your HTML looks something like this:

<form action="...">
   <input type="hidden" name="thankyou_url" value="">

Here you see a “hidden” URL with “thankyou” in the name and a value that points to the Thank You page you specified when you created the form.

To pass your Sub-ID, you simply need to add the [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="[s1]">

If you’ve added the JavaScript Sub-ID code from Step 1, this will take the 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.

The “[” and “]” characters are not allowed in URLs, so some autoresponders won’t let you directly enter the [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.

What if there isn’t a Thank You page URL?

If your autoresponder doesn’t generate HTML code or doesn’t include the Thank You page URL when it does, then check the JavaScript code that it generates and look for the URL there. If you find one, follow the instructions in Step 3 to modify the JavaScript code correctly.

If for some reason, you simply cannot edit the Thank You page URL in the HTML or JavaScript code generated by your autoresponder, then you’ll need to read their documentation to see how you can pass “custom values” through their system.

If you can’t immediately find help for passing “custom values”, contact your autoresponder service for help with this. Remember, they know their system inside out and they are the experts for their system, not us …

Generally speaking, if you can’t modify the Thank You page URL, you’ll instead have to pass custom values in hidden data fields like this:

<input type="hidden" name="custom1" value="[s1]">
<input type="hidden" name="custom2" value="[s2]">

Once you’ve done this, you can then pass the custom values on to your Thank You page URL using whatever tokens your autoresponder system supports. You’ll need to set that part up inside your autoresponder settings.

If you need help configuring your autoresponder to pass custom values, contact the support folks for your autoresponder for help with this.
Caution: Modifying the <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=[s1]">

The need for a “meta refresh” usually comes up when you’re trying to create an intermediate or interstitial page to fire a tracking pixel. ClickMagick has a more effective approach using the advanced Pixels setting of tracking links. You can get all the details in this article:
How can I set up an intermediate page to fire a pixel?

Article 399 Last updated: 10/12/2020 7:26:44 AM