Skip to content

Instantly share code, notes, and snippets.

@fIa5h
Created December 20, 2018 19:57
Show Gist options
  • Save fIa5h/0529b510dc7663a7c669037501d56e83 to your computer and use it in GitHub Desktop.
Save fIa5h/0529b510dc7663a7c669037501d56e83 to your computer and use it in GitHub Desktop.
Installation script for Intercom to include current URL as a field on the lead object passed to SFDC
<script>
/*
INSTRUCTIONS
To begin syncing this parameters with SFDC you will need to excplitly reference
them as qualification attributes in your Intercom Qualification Data settings in the Intercom UI:
https://www.intercom.com/help/faqs-and-troubleshooting/capture-qualify-and-convert-leads/what-is-qualification-data
Then, you will need to map those qualification attributes to your SFDC lead fields in the Intercom UI.
See the "Map and sync your qualification attributes" section of this document:
https://www.intercom.com/help/apps-in-intercom/apps/salesforce-app
*/
//Set your APP_ID
var APP_ID = "*** YOUR APP ID ***";
//Instantiate our window.intercomSettings object
window.intercomSettings = {
app_id: APP_ID
};
try {
window.intercomSettings["intercom referral URL"] = window.location.href;
}
catch(err) {}
//Then the standard Intercom instantiation 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;
function l() {
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);
}
if (w.attachEvent) { w.attachEvent('onload', l); } else { w.addEventListener('load', l, false); }
}
})()
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment