How to add Facebook chat widget code to a website with Google Tag Manager

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:

<script>
     var body=document.getElementsByTagName('body')[0];
     var script=document.createElement('script');
     script.async=true;
     script.src='//fbstore.sendpulse.com/loader.js';
     script.setAttribute('data-sp-widget-id','YOUR WIDGET ID');
     body.appendChild(script);
</script>

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 which will invoke the tag.

Trigger configuration

Save the tag.

Saving the tag

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

Submitting the workplace changes

Rate this article about "How to add Facebook chat widget code to a website with Google Tag Manager"

User Rating: 5 / 5 (7)

    Other useful articles

    Popular in Our Blog

    Try a free chatbot for Facebook Messenger