Last active
February 7, 2019 03:35
-
-
Save alexkappa/7ba3252b7531cd3a33d503c689d86326 to your computer and use it in GitHub Desktop.
Install Intercom using Google Tag Manager
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
'sload
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.