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.
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:
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:
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:
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.
Get Exclusive Elevar Insights directly to your inbox.
Get free analytics tips and resources delivered directly to your inbox.
Conversion Rate Falling Flat?
Avoid The 9 Mistakes That Prevent Conversion Rates from ScalingDownload Now