Sample HTML Track Events

Hi all,

I set up a Snowplow mini in AWS and I am trying to create my own tracking. The Snowplow Mini UI works fine but this sample HTML do nothing.

What am I doing wrong?

<HEAD>
  <!-- Snowplow starts plowing -->
  <script type="text/javascript">
    ;(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","http://d1fc8wv8zag5ca.cloudfront.net/2.9.0/sp.js","snowplow"));
    
    snowplow('newTracker', 'sp', 'http://myip/com.snowplowanalytics.snowplow/tp2', {
        appId: 'my-app-id',
    });
    
    snowplow('enableActivityTracking', {
      minimumVisitLength: 30,
      heartbeatDelay: 10
    });
    snowplow('trackPageView');
    
    </script>
</HEAD>
<BODY onload="snowplow('trackPageView');">
  <h1>Snowplow Test</h1>
  <a href="https://www.google.com" onClick="google();">Track Google</a>
  <a href="https://bing.com" onClick="ad();">Track Ad</a>
  </BODY>```

For the collector URL you’ll want something like collector.example.com (with no protocol and no path) just the domain / subdomain itself.

Domain and subdomain you mean where the collector has been installed?

Yes.

@nando_roz, you can use just IP address if myip is actually the IP address of the collector (you can see the pixel when navigating to http://xxx.xxx.xxx.xxx/i). The point here is, you do not need to add /com.snowplowanalytics.snowplow/tp2 to the URL of the collector in your tracker initialization code. The tracker will add that endpoint automatically if you are using POST method (which it is by default).

However, as Mike pointed out, you should be using proper domain for the collector (again, without /com.snowplowanalytics.snowplow/tp2) since cookie handling depends on the collector name.

The CDN you’re using to load the sp.js file is also deprecated. You should use jsDelivr directly (which the deprecated CDN redirects to). Also 2.9.0 is really out of date.

For v2, you should use https://cdn.jsdelivr.net/gh/snowplow/sp-js-assets@2.18.0/sp.js

Thank you all. Just to clarify. I am using Snowplow Mini image in AWS Cloud. I messed to upload a Iglu Server config file.

And change de collector information and the CDN.

Now working fine