Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign up| // 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]); | |
| } | |
| }); | |