Snowplow Mini JS Tracker not able to send events to Collector

Hi Guys,

Have been putting my head into setting up this for a long time now. I made an e-Commerce website using Magento, and then I am adding JS tracker to this after setting up & running my Snowplow Mini instance on AWS. Everything shows up perfectly on Snowplow, even the Example Events are working fine, but I don’t know why using JS tracker I am unable to end events to my Snowplow Mini collector so as to subsequently display it in Kibana Discover

I am adding the below JS in my in my Magento application. I even tried using this JS tracker code in other web applications, it still does not work. Would be great if anyone can help me here, I’m stuck.

<!-- 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.10.0/sp.js","snowplow"));
    var collector = "ec2-XX-XXX-XXX-XX.compute-1.amazonaws.com";
    window.snowplow('newTracker','rt',collector,{
             appId: "snw6"
    });
snowplow(function () { console.log("sp.js has loaded"); });
snowplow('enableActivityTracking', 10, 10);
console.log("Adding Item");
snowplow('addItem',
          '000000002',           // order ID - required
          'WS08-XS-Blue',
          'Minerva LumaTech™ V-Tee',        // product name
          'Blue XS',   // category or variation
          '32.00',          // unit price - required
          '1'               // quantity - required
        );
window.snowplow('trackPageView');
console.log("Success")
  </script>
     <!-- Snowplow stops plowing -->

Really don’t know where am going wrong.

Thanks
Kuzhal

@Kuzhal, is your Magento eCommerce site accessed via HTTPS (secure web site)? If so then maybe you have a problem loading the JS tracker which you access via HTTP (non-secure content)

(window,document,"script","http://d1fc8wv8zag5ca.cloudfront.net/2.10.0/sp.js","snowplow"));

You might want to replace http://d1fc8wv8zag5ca.cloudfront.net/2.10.0/sp.js with //d1fc8wv8zag5ca.cloudfront.net/2.10.0/sp.js.

On a side note, I would recommend JS tracker 2.10.2 which has fixes for a few bugs in 2.10.0.

Additionally, addItem method on its own will not work. You need to create a transaction, add item(s) to that transaction and then push it to the collector with trackTrans: https://github.com/snowplow/snowplow/wiki/2-Specific-event-tracking-with-the-Javascript-tracker#33-ecommerce-tracking.

Still, I would expect you to be able to track pageviews.

Have you checked the requests in Developer Console of the browser (Console and Network tabs)? Do any errors appear in there? Just wonder if

  • you load the JS tracker
  • you send the events to the collector
  • any Javascript errors preventing tracking code to function
2 Likes