5. Creating Custom GTM Variables

Custom GTM Variables

To actually get this data into your GTM and then into your GA4 account, you will need to create what's called "Custom Variables" in GTM. I will show you how to do this, and I will link to Google's help documentation if you need further assistance. By following my exact directions, you will be able to create custom variables for any and all widget event data you want to track.

IMPORTANT: Every widget event sends potentially different data. For example, if the widget event is "widget opened" you will not see specific data for a "tool". So to get every single data point you will need to test all 7 widget events.

IMPORTANT: ChatHQ may also add more widget events in the future, or add more data points to existing widget events. Please keep that in mind.

You can also request specific data and we will do our best to add it to the JSON payload.

Creating Custom Variables

  • First, you need to open the GTM Tag that you want to add custom variables to. For this example I am using the "Tool Opened" widget event tag in my GTM. When adding custom variables, you will need to identify if the variable falls under "EVENT PARAMETERS" or "USER PROPERTIES".

Event Parameters consist of data that refers to the widget such as:

  • Widget ID

  • Tool Name

  • Tool ID

  • Welcome Message ID

  • Ect

User Properties consist of data that refers to users and accounts such as:

  • User ID

  • Account ID

  • Location ID

  • Contact

  • Token

  • Ect

  • Depending on the type of variable you're adding, you want to "add a new row" to that specific section as shown in the screenshot below. In this example, I am adding a custom variable in "EVENT PARAMETERS" for the data set "toolId".

  • Next, you will need to click the small icon on the far right of the input field that looks like a Leggo with a + sign in the middle of it.

  • Once you click that button, you will see a new screen. On this new screen, you will see a list of GTM variables. This is where you will see all the custom variables you've created moving forward. To create a new custom variable, click the "+" sign in the top right corner of the screen.

  • Next, you need to select the category of variable you are adding to your GTM. You will need to select the "DATA LAYER VARIABLE" as shown in the screenshot below:

  • After selecting the "DATA LAYER VARIABLE" category, you will only need to configure 2 fields to finish setting up your custom variable:

    • Variable Name

    • Data Layer Variable Name

  • After you save your new customer variable, you will now see it show up in the previously empty row you created earlier in this process. The last step is to simply add a "PARAMETER NAME" that will show up in your GA4 analytic dashboards and reports. You will notice in the image below that the "PARAMETER NAME" on the left looks clean and has no special characters like {}, and the "VALUE NAME" on the right is enclosed in curly brackets {} because that is the custom variable you just created in the previous steps.

Submit Changes

Lastly, you need to submit the changes made to your GTM and you're all done!

If you try to test before you submit your changes, you WILL NOT see the correct data

Adding More Event Parameters

Event Parameters consist of the widget data that is collected when events are triggered in the widget. ChatHQ surfaces many different widget data points that are available to you to track and quantify. This information is found in the Data Layer.

  • Parameter Name - widget | Value - {{Widget ID}}

    • This parameter will show up in your Google Analytics so you can identify which events came from which widget using the Widget ID, and set up filters and reports around it.

  • Parameter Name - element | Value - {{UI Element}}

    • This parameter will show up in your Google Analytics so you can identify the name of the UI Element that triggered the widget event, and set up filters and reports around it.

Adding More User Properties

User Properties consist of the user data that is collected when events are triggered in the widget. ChatHQ surfaces many different user data points that are available to you to track and quantify. This information is found in the Data Layer.

  • Property Name - contactId | Value - {{Contact ID}}

    • This user property will show up in your Google Analytics so you can identify the Contact ID of the individual using your widget, and set up filters and reports around it. This works GREAT when using your widget in your HighLevel for support!

  • Parameter Name - locationId | Value - {{Location ID}}

    • This user property will show up in your Google Analytics so you can identify the Location ID of the individual using your widget, and set up filters and reports around it. This works GREAT when using your widget in your HighLevel for support!

Last updated