Adapted script format for Google Tag Manager
If you’re implementing these chat attributes in Google Tag Manager rather than directly in the CSS of your website, the Div function needs to be converted to a script because GTM does not accept the CSS format. Note that this script should be fired in a separate tag from the chat snippet that initializes the widget. This tag should be fired before the tag that initializes the chat since this tag tells the other how it should be loaded.
Here’s an example of that script already formatted, the values in line 4 would just need to be populated with the attribute you want to configure:
Here’s a completed example using the Widget State attribute:
The normal div function if we wanted the chat to open in the welcome state would look like the following:
The adapted script takes the attribute (widget_state) and the attribute value (welcome) and replaces the elements in line 4:
If you want to use a combination of attributes, they can all be added to the same script, just add another line using the same div.setAttribute configuration:
Last updated