How to Add Chat Widget Code to a Website with GTM

Create a Facebook chat widget.

To add the chat widget to a website with the help of Google Tag Manager, you will need the widget ID.

Chat widget code

In the Google Tag Manager account, create a new tag.

Creating a new tag

Select the "Custom HTML" tag type.

Selecting a tag type

Add the following script into the "HTML" field in the "Tag Configuration" form:

     var body=document.getElementsByTagName('body')[0];
     var script=document.createElement('script');
     script.setAttribute('data-sp-widget-id','YOUR WIDGET ID');

Where 'YOUR WIDGET ID' is the ID which you get after generating widget code in the SendPulse service.

Script for adding a chat widget to a website

Configure triggers that will invoke the tag.

Trigger configuration

Save the tag.

Saving the tag

The widget will appear on the website sometime after you submit the workspace changes in Google Tag Manager.

Submitting the workplace changes

Rate this article about "How to Add Chat Widget Code to a Website with GTM"

User Rating: 5 / 5

    Popular in Our Blog

    Try creating a chatbot for Facebook Messenger for free