In order to track WebEngage Events with Google Tag Manager (GTM) with Universal or Classic Analytics Tag Type, you would have to implement the solution in two steps:
Step 1: Google Tag Manager (GTM) Configuration for WebEngage Event Tracking
- First Create a new Tag inside your GTM dashboard.
- Give an appropriate title (e.g. ‘GA-Events’) and then select tag type as ‘Google Analytics > Universal/Classic Analytics‘.
- Copy the tracking-id from your Google Analytics account and then paste it in the Tracking ID
field of your GTM.
- Set ‘Track Type’ of your Tag to ‘Event’. Since we are using dataLayer API of GTM, you will need to add appropriate macros for all the parameters. Refer the below image for the same.
- For Non-Interaction Hit you might have to add a dataLayer Macro. See the image below.
- Now, go to the ‘Firing Rules‘ section and click on add to insert rule.
- An edit rule window would open up. Give a suitable name for your rule and in the ‘Conditions‘ section add ‘event‘ condition with operation set to ‘equals‘ and values ‘WebEngage-Survey‘. Save to add the rule.
- Then repeat step 5 and 6 for events ‘WebEngage-Notification‘ and ‘WebEngage-Feedback‘. Refer the following three images.
Step 2: WebEngage Widget Integration Code Changes
- Add the line _weq[‘webengage.ga.gtm’] = true; in the WebEngage widget integration code. This would let WebEngage Widget know that you are using Universal GA with GTM.
- Optionally, if you want to track for a specific GA tracking-id when you have both classic and universal GA, add the line _weq[‘webengage.ga.trackerId’] = ‘UA-XX-XXXX’; in the widget integration code.
- If you are using custom value for the GoogleAnalyticsObject instead of default value (viz. ‘ga’) then add the line _weq[‘GA.universalAnalyticsFunction’] = ‘myGA’; in the widget integration code.