Google Tag Manager
Google Tag Manager allows you to pass data through the GTM data layer.
Google Tag Manager Integration Setup: Shopify Script Tag (i.e. not Shopify Checkout Extensions)
Our Google Tag Manager (GTM) integration can be enabled by toggling our Google Analytics integration to active.
Google Tag Manager Integration Setup: Shopify Checkout Extensions
- Create a new Custom Pixel from your Shopify Admin (Go to Settings >> Customer Events)
- Click 'Add custom pixel'
- Put the following javascript code into the code block
- NOTE: Replace 'G-XXXX' with your GTM ID. You can find your GTM ID in GTM under Admin
//Initialize GTM
(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-XXX');
analytics.subscribe("fairing_question_view", event => {
window.dataLayer.push({
event: "fairing_question_view",
order_id: event.orderId,
question_id: event.questionPrompt,
question: event.questionId,
});
});
analytics.subscribe("fairing_question_response", event => {
window.dataLayer.push({
event: "fairing_question_response",
order_id: event.orderId,
other: event.other,
question_id: event.questionId,
question: event.questionPrompt,
response: event.response,
});
});
Accept Events from Custom Pixel
- Create a trigger for each Fairing event - Fairing Question View and Fairing Question Response
- Trigger Type = Custom Event
- Event Name = fairing_question_view and fairing_question_response
-
Create a tag for each event to connect to your GA account
- Enter your Measurement ID from the GA account you want to connect to
GTM Data Layer
Once enabled (and if you have GTM properly installed), you'll find the below values being passed through the GTM data layer.
{
gtm:{start: 12345, uniqueEventId: 4},
event: "Enquire Survey Response",
question: "How did you hear about us?",
response: "Word of mouth",
availableResponses: [
"Facebook",
"Word of mouth",
"Retail Store",
"Online Advertisement",
"Instagram",
"other"
],
order_id: 987654321,
other: "false"
}
To utilize these values, you'll need to create custom variables in GTM. Here is a quick video on how to do so:
Updated 10 months ago