4. Using the Data Layer to Define Custom Variables
Last updated
Last updated
Learn more about the Data Layer and how to access/use the information found in the Data Layer here: https://developers.google.com/tag-platform/tag-manager/web/datalayer
In order to access the data layer and see what data is being sent from the widget into your GTM, you need to run your website in "Debug" mode using the Google Tag Assistant Chrome Extension.
Download the Chrome Extension here: https://chrome.google.com/webstore/detail/tag-assistant-companion/jmekfmbnaedfebfnmakmokmlfpblbfdm?hl=en
Next, you will need to open your newly added Chrome extension and add the domain you have your Engagement Widget installed on.
If you do not have your Google Tag Manager script installed on this website, the debugging process will not work.
Once you add your domain, you will see a screen that looks like the screenshot below, and you will start to see all actions on your website stream into the Tag Assistant.
Make sure you select the correct GTM account ID at the top of the screen so you see the correct events flowing into your Tag Assistant.
You can learn more about using the Tag Assistant by reading Google's help docs here: https://support.google.com/tagassistant/answer/10039345
Now that you have your Tag Assistant setup and you have selected the correct GTM account, any actions you perform on your website will start showing up in the "Summary" sidebar in Tag Assistant, including the widget events that ChatHQ sends when you interact with a ChatHQ Engagement Widget™.
The next step is to interact with the widget installed on the website that is being tracked by your Tag Assistant. By performing any of the following events, you will see the events and data show up in your Tag Assistant.
widget_opened
widget_closed
tool_opened
tool_closed
welcome_message_clicked
welcome_message_closed
all_welcome_messages_closed
Now that we have widget events showing up in the Tag Assistant, you will need to inspect the data layer to see exactly what data can be used when setting up custom Tags in your Google Tag Manager.
Below you will see an actual JSON payload of the widget event data passed into the Google Tag Assistant. You will see many different data points that you can capture and use in your analytics for various use cases.
This specific event occurred when I "Opened a Tool" inside my Engagement Widget. You will notice at the bottom of this JSON payload, there is a "tool" and "toolId" field.
You can actually identify which tool was opened so you know exactly what actions your website visitors took before they converted!
For the next steps, I am going to identify the data variables I want to pass into my widget analytics by looking at the data layer above. I will be setting up analytics for the following data points:
account: "CHATHQ ACCOUNT ID"
widget: "YOUR WIDGET ID"
token: "BROWSER SESSION TOKEN"
el: "tool_item"
tool: "tool-reviews"
toolId: "UYRLaZjNJz4Qhzv6lnD9c"