Instructions to use Google Tag Manager Integration.
Google Tag Manager needs a piece of code inside the body to work properly. At this point, let’s assume that it’s added, and we only need to add the code for the Tagging.
For detailed instructions about this, go to: https://support.google.com/tagmanager/answer/6103696
The first thing to do is initialize dataLayer variable. The piece of code that initializes the variable is:
<script> dataLayer = []; </script> |
This piece of code must be in all the pages that contain the search bar. There are two options:
Add this code just before the Google Tag Manager code:
<body> <script> dataLayer = []; </script> <!-- Google Tag Manager --> ... <!-- End Google Tag Manager --> |
The second thing to do is to add the event to dataLayer. This is and example.
<script> dataLayer.push({ 'eventTrackUrl': 'https://api-staging.empathybroker.com/tagging/v1/track/clientname/query?q=query&catalog=default&scope=default&store=default&lang=en&totalHits=74&page=1', 'eventCallback': callback, 'event': 'sendTrackEvent' }); </script> |
Configure Tag:
eventTrackUrl: {{trackUrl}} //Variable created on point 5
eventCallback: {{callback}} //Variable created on point 5
<script src="https://assets.empathybroker.com/apijs/1.3/empathy.resources.min.js" type="text/javascript"></script> <script> var empathyTAG = new EmpathyBrokerTAG(INSTANCE_ID, ENVIRONMENT).init(); empathyTAG.sendTrack({{trackUrl}}, {{callback}}); </script> |
Fire On: More > Choose from existing Triggers: sendTrackEvent
Create Tag
Related articles appear here based on the labels you select. Click to edit the macro and add or change labels.