Collecting Data

More than 20 SDKs available

Snowplow has 20 SDKs available for different programming languages. You can collect events client-side and/or server-side.

Google Tag Manager Custom Templates

Snowplow created two GTM templates to facilitate the implementation of Snowplow within Google Tag Manager. Please see their documentation for complete reference.

Javascript V2 Tracker

Please read the complete documentation on Snowplow v2 JS Tracker.

Tracking events is simple, first load the sp.js tracker, then initialize it, and it is ready to track events.

Snowplow recommends renaming sp.js as this file name is commonly blocked by adblockers. Renaming to a random string will help ensure the JavaScript Tracker is loaded as expected. It is also recommended to host the Javascript tracker under your domain.

Tracker setup and initialization with basic options.

<script>
  // Load the Tracker
  (function(p, l, o, w, i, n, g) {
    if (!p[i]) {
      p.GlobalSnowplowNamespace = p.GlobalSnowplowNamespace || [];
      p.GlobalSnowplowNamespace.push(i);
      p[i] = function() {
        (p[i].q = p[i].q || []).push(arguments);
      };
      p[i].q = p[i].q || [];
      n = l.createElement(o);
      g = l.getElementsByTagName(o)[0];
      n.async = 1;
      n.src = w;
      g.parentNode.insertBefore(n, g);
    }
  })(
    window,
    document,
    "script",
    "//cdn.jsdelivr.net/gh/snowplow/sp-js-assets@2.18.0/sp.min.js",
    "snowplow"
  );

  // Initialization
  window.snowplow("newTracker", "cf", "sp.yourcollector.com", {
    appId: "yourappid",
    discoverRootDomain: true,
    cookieSameSite: "Lax", // Recommended
    contexts: {
      webPage: true,
    },
  });
</script>

Tracking a page view, and a page view with schema.

<script>
  snowplow("trackPageView");
</script>
<script>
  var context = [
    {
      schema: "iglu:com.vendor/schema_name/jsonschema/1-0-0",
      data: {
        datapoint: "Value",
        second_datapoint: "Other value",
      },
    },
  ];

  snowplow("trackPageView", null, context);
</script>