Skip to content

Instantly share code, notes, and snippets.

@alexkappa
Last active February 7, 2019 03:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexkappa/7ba3252b7531cd3a33d503c689d86326 to your computer and use it in GitHub Desktop.
Save alexkappa/7ba3252b7531cd3a33d503c689d86326 to your computer and use it in GitHub Desktop.
Install Intercom using Google Tag Manager
<script>
window.intercomSettings = {
app_id: 'APP_ID',
name: "Jane Doe", // Full name
email: "customer@example.com", // Email address
created_at: 1312182000 // Signup date as a Unix timestamp
};
</script>
<script>
(function() {
var w = window;
var ic = w.Intercom;
if (typeof ic === "function") {
ic('reattach_activator');
ic('update', intercomSettings);
} else {
var d = document;
var i = function() {
i.c(arguments)
};
i.q = [];
i.c = function(args) {
i.q.push(args)
};
w.Intercom = i;
var s = d.createElement('script');
s.type = 'text/javascript';
s.async = true;
s.src = 'https://widget.intercom.io/widget/APP_ID';
var x = d.getElementsByTagName('script')[0];
x.parentNode.insertBefore(s, x);
}
})()
</script>
@alexkappa
Copy link
Author

In case someone else is having similar trouble as us, I'm posting the modified version of the Intercom tag that works with Google Tag Manager.

The original version binds to the window's load event in order to load the Intercom widget. The event is typically dispatched before GTM places the Intercom tag therefore the widget never loads.

The modified version will load the Intercom widget immediately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment