3.6.0 • Published 7 months ago

@surfside/digital-sdk v3.6.0

Weekly downloads
-
License
-
Repository
-
Last release
7 months ago

Snowplow JavaScript Tracker

Add Surfside Tracking to your website via a tag solution.

Maintainer quick start

Part of the JavaScript Tracker monorepo.
Build with Node.js (12 LTS or 14 LTS) and Rush.

Setup repository

npm install -g @microsoft/rush 
rush update

Select your version

This repository creates two versions of the tracker.

The fully featured edge.js contains the majority of the plugins included within this repository for a complete tracking experience. This is our recommended version.

However, if you'd like a lightweight version of the tracker you can opt for edge.lite.js.
This version only includes Page Views, Page Activity, Structured and Self Describing events as well as global contexts and anonymous tracking.

Installation

Add the tag to your website or Tag Management solution:

<script type="text/javascript" async=1>
;(function(s,u,r,f,i,n,g){if(!p[i]){p.surfContext=p.surfContext||[]; p.surfContext.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","{{URL to sp.js}}","snowplow"));
</script>

<script>
window.surf('newTracker', 'sp', collector_endpoint, {
  appId: 'my-app',
  eventMethod: 'post',
  contexts: {
    performanceTiming: true,
  },
});
</script>

We advise you host edge.js or edge.lite.js yourself, and rename it.

Usage

window.surf('enableLinkClickTracking');

window.surf('trackPageView', {
  title: 'My Title',
  context: [
    // Set page title; add page context
    {
      schema: 'iglu:org.schema/WebPage/jsonschema/1-0-0',
      data: {
        keywords: ['tester'],
      },
    },
  ],
});

window.surf('trackSelfDescribingEvent', {
  event: {
    schema: 'iglu:com.acme/my_event/jsonschema/1-0-0',
    data: {
      myId: '12345-abc',
    },
  }
});

Additional Plugins

Can be injected by modifying the package.json to include package name or declaring the local plugin via rush.json config

Examples: "@snowplow/browser-plugin-ad-tracking": "workspace:", "@snowplow/browser-plugin-browser-features": "workspace:", "@snowplow/browser-plugin-client-hints": "workspace:", "@snowplow/browser-plugin-consent": "workspace:", "@snowplow/browser-plugin-ecommerce": "workspace:", "@snowplow/browser-plugin-enhanced-ecommerce": "workspace:", "@snowplow/browser-plugin-error-tracking": "workspace:", "@snowplow/browser-plugin-form-tracking": "workspace:", "@snowplow/browser-plugin-ga-cookies": "workspace:", "@snowplow/browser-plugin-geolocation": "workspace:", "@snowplow/browser-plugin-link-click-tracking": "workspace:", "@snowplow/browser-plugin-media-tracking": "workspace:", "@snowplow/browser-plugin-optimizely": "workspace:", "@snowplow/browser-plugin-optimizely-x": "workspace:", "@snowplow/browser-plugin-performance-timing": "workspace:", "@snowplow/browser-plugin-site-tracking": "workspace:", "@snowplow/browser-plugin-timezone": "workspace:", "@snowplow/browser-plugin-youtube-tracking": "workspace:"

Copyright and license

Licensed and distributed under the BSD 3-Clause License (An OSI Approved License).

Copyright (c) 2022 Surfside Solutions Inc, Snowplow Analytics Ltd, 2010 Anthon Pang.

All rights reserved.