Analytics.js for Platforms

The ecosystem of marketing and analytics tools is growing insanely fast, and most web platforms face tons of requests from their customers to build new destinations. But adding more destinations is hard: it requires thinking about how each one needs to work, the use cases for different customers, what data needs to be collected and where it needs to be sent. As the number of destination grows, the complexity of maintenance increases as well.

Analytics.js for Platforms gives web platforms four destinations out of the box: Google Analytics, Google Adwords, Facebook Ads and Segment. The first three cover 99% of destination needs for most small businesses, while Segment gives an escape valve to another 200+ destinations for advanced customers.

If you have questions or want to talk to our partnerships team, email


To load Analytics.js for Platforms, include this snippet on your page and initialize with the customer-specific destination settings.

!function(){var||[];if(!analytics.initialize)if(analytics.invoked)window.console&&console.error&&console.error("Segment snippet included twice.");else{analytics.invoked=!0;analytics.methods=["trackSubmit","trackClick","trackLink","trackForm","pageview","identify","reset","group","track","ready","alias","debug","page","once","off","on"];analytics.factory=function(t){return function(){var;e.unshift(t);analytics.push(e);return analytics}};for(var t=0;t<analytics.methods.length;t++){var e=analytics.methods[t];analytics[e]=analytics.factory(e)}analytics.loadPlatform=function(t,e,a,o){window[o||"analytics"]=analytics;window._analytics_js_global_name=o;analytics.platformSettings=e;analytics.platformPlan=a;var n=("https:"===document.location.protocol?"https://":"http://")+"";t&&(n+="/"+t);var r=document.createElement("script");r.type="text/javascript";r.async=!0;r.src=n+"/platform/analytics.min.js";var i=document.getElementsByTagName("script")[0];i.parentNode.insertBefore(r,i)};analytics.SNIPPET_VERSION="4.0.0_platform";
analytics.loadPlatform("WRITE_KEY", {
... SETTINGS ...

Initializing takes two arguments, both optional but at least one required:

  • writeKey — the customer’s Segment write key, found on the Settings → API Keys page in their Segment account. If the customer does not have a Segment write key, pass null or an empty string

  • settings — an object containing a map of destination name to settings for that destination, detailed below. destination Settings

Each destination has a set of required and optional settings that change how it functions

Google Analytics



  enhancedEcommerce: true,
  includeSearch: true,
  nonInteraction: true,
  sendUserId: false,
  trackingId: 'UA-1234567890-1'




  conversionId: 123456789,
  remarketing: true,
  whitelist: [ 'Product Viewed' ]

Facebook Pixel



  pixelId: '828394912385812',
  initWithExistingTraits: false