Skip to content
Permalink
43887b4428
Go to file
 
 
Cannot retrieve contributors at this time
49 lines (37 sloc) 1.51 KB
// HubSpot
// -------
// Last updated: December 13th, 2012
// [Documentation](http://hubspot.clarify-it.com/d/4m62hl)
analytics.addProvider('HubSpot', {
settings : {
portalId : null
},
// Changes to the HubSpot snippet:
//
// * Adding HubSpot snippet
// Use the `portalId` to setup the HubSpot tracking code.
initialize : function (settings) {
settings = analytics.utils.resolveSettings(settings, 'portalId');
analytics.utils.extend(this.settings, settings);
var self = this;
(function(d,s,i,r) {
if (d.getElementById(i)){return;}
window._hsq = window._hsq || []; // for calls pre-load
var n=d.createElement(s),e=d.getElementsByTagName(s)[0];
n.id=i;n.src='https://js.hubspot.com/analytics/'+(Math.ceil(new Date()/r)*r)+'/' + self.settings.portalId + '.js';
e.parentNode.insertBefore(n, e);
})(document,"script","hs-analytics",300000);
},
identify : function (userId, traits) {
// HubSpot does not use a userId, but the email address is required on
// the traits object.
if (!traits) return;
window._hsq.push(["identify", traits]);
},
// Event Tracking is available to HubSpot Enterprise customers only. In
// addition to adding any unique event name, you can also use the id of an
// existing custom event as the event variable.
track : function (event, properties) {
window._hsq.push(["trackEvent", event, properties]);
}
});
You can’t perform that action at this time.