GTM

How to Use Affiliate Query Parameters in GTM Tags

See how to store inbound affiliate IDs in a GTM variable for use in your own GTM marketing tags in 3 easy steps.

How to Use Affiliate Query Parameters in GTM Tags

Since the launch of our GTM App for Shopify we’ve had a bunch of great questions on how to help with various affiliate tagging. This particular request has come up a few times so I thought I’d share how to do this outside of our app.

Here’s an example of one of the questions:

Hi Brad, I was checking out the GTM shopify app. I was wondering if the app is capable of passing parameters back in different 3rd pixels. For example if we work with an affiliate an they’re passing x=123456789 can we capture this value and pass it back in their pixel

If this is a simple request of “I need to pass the first entrance hit with this affiliate ID” then this can be done by doing the following:

Step 1: Create Query Key Variable

Inside of GTM > Variables > User Defined Variables create a new query variable where “x” from the quote above is where you’d put in place of cjevent:
query-key-parameter

Step 2: Insert Variable into Sitewide Affiliate Tag

This step requires you to use this variable in the affiliate tag. Based on the requirements of your tag you’ll need to set the variable you created in step 1 into the tag variable as shown below:

affiliate-tag-query-parameter

Step 3: Verify via GTM Preview Mode

Now you just need to verify this works as you expect by putting your affiliate query parameter into your website URL => reloading the page => viewing the tag that you configured in step 2 as shown here in the GTM debug console:

affiliate-tag

Questions? Let me know in the comments. I’ll show how to create cookie to store this value as the next step to this process.


Brad Redding

Brad, co-founder of Elevar, has lived in eCommerce for over 12 years. He's helped design, build, and optimize over 100 websites in his career. From new retail startups to well-known brands like Le Creuset, Signature Hardware, Rebecca Minkoff, Char-Broil and more, he specializes in data analytics and conversion optimization to help achieve business goals.

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Articles

Talk with Us

Please complete the form to request a demo, discuss our solutions, or to just say hi!



Some of our clients