How to Set Up Commission Junction on Shopify via GTM
This guide shows how to set up your Commission Junction affiliate tracking via Google Tag Manager for Shopify stores.
This works for all stores and can be used for Shopify checkout as well as other third party checkouts like ReCharge where we have access to the thank you page script settings.
What is in the container:
- 2 Tags
- 2 Triggers
- 10 Variables
First, the variables:
These 3 variables are the constants that CJ provides in their onboarding documentation:
- Container Tag ID
You will need to update these variables in your account from our dummy account #s.
Then we have the CJ query parameter.
This is the query parameter found in the URL when a CJ referral lands on your site. It would look like something like this: www.getelevar.com?cjevent=12345
cjevent is the query parameter key we need to create the variable for and is what CJ uses to match back to their advertiser.
Next we have the “Cookie – CJ” variable which is a 1st party cookie where the cookie name is cjevent.
I’ll show how this is set in the global CJ tag.
The remaining variables:
- Order ID
- Products purchased
- Discount name
- Discount code
Are all variables that come out of the box with the Google Tag Manager Data Layer app on the Shopify app store.
Next, the triggers
The Pageview – CJ event trigger executes when the Page URL contains “cjevent” in the URL
It’s important that this is Page URL and not Page Path so the query parameters are accessible.
The second trigger is a Transaction Complete custom event. This also comes native with the GTM App linked above in the Shopify app store.
Lastly, the Tags
We can now put together the integration in two simple tags.
The first: Commission Junction – Set Cookie is a tag that essentially grabs the cjevent query parameter value and stores it in a 1st party cookie on your site.
This cookie is persistent across all pages of your site, including subdomains.
The second tag is our conversion tag.
This contains all variables required for sending conversion data back to CJ.
It is very important that the data layer variables are created on the Shopify Thank You page script settings via the GTM app.