Nuclear Pumpkin Mayhem

    @snowplow/javascript-tracker

    3.6.0 • Public • Published

    Snowplow JavaScript Tracker

    npm version License

    Add Snowplow Tracking to your website via a tag solution.

    Maintainer quick start

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

    Setup repository

    npm install -g @microsoft/rush 
    git clone https://github.com/snowplow/snowplow-javascript-tracker.git
    rush update

    Select your version

    This repository creates two versions of the tracker.

    The fully featured sp.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 sp.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(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","{{URL to sp.js}}","snowplow"));
    </script>
    
    <script>
    window.snowplow('newTracker', 'sp', collector_endpoint, {
      appId: 'my-app',
      eventMethod: 'post',
      contexts: {
        performanceTiming: true,
      },
    });
    </script>

    We advise you host sp.js or sp.lite.js yourself, and rename it. However if you'd like use a CDN, you'll find the tracker on jsDelivr, unpkg and cdnjs.

    Usage

    window.snowplow('enableLinkClickTracking');
    
    window.snowplow('trackPageView', {
      title: 'My Title',
      context: [
        // Set page title; add page context
        {
          schema: 'iglu:org.schema/WebPage/jsonschema/1-0-0',
          data: {
            keywords: ['tester'],
          },
        },
      ],
    });
    
    window.snowplow('trackSelfDescribingEvent', {
      event: {
        schema: 'iglu:com.acme/my_event/jsonschema/1-0-0',
        data: {
          myId: '12345-abc',
        },
      }
    });

    Copyright and license

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

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

    All rights reserved.

    Install

    npm i @snowplow/javascript-tracker

    Homepage

    bit.ly/sp-js

    DownloadsWeekly Downloads

    878

    Version

    3.6.0

    License

    BSD-3-Clause

    Unpacked Size

    1.72 MB

    Total Files

    61

    Last publish

    Collaborators

    • snowplow-analytics
    • cogsp
    • paul_boocock