I have been using Snowplow Mini for testing for the last couple of days.
I have been able to track standard events such as trackPageView, and a structured event. I uploaded a custom schema to Snowplow Mini, and have not been able to get it to actually track anything. I changed it to “public” based on seeing a previous post on here, as well as changing the tracking argument from trackUnstructEvent, to trackSelfDescribingEvent, as the argument is different in different areas of the documentation. I have confirmed that my schema is being hosted in the EC2 instance at the address I am pointing to by navigating to that page. Right now I am just using an example Schema provided in Documentation to prove that it works, but I want to get this working so I can move onto developing more useful custom schemas. Help is appreciated!
Below is my code, I edited out the instanceIP, but other than that, trackPageView and trackStructEvent are currently working.
<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', 'cf', '//{{instanceIP}}.us-east-2.compute.amazonaws.com', { // Initialise a tracker
appId: 'TomSnowplowMini',
cookieDomain: 'TomSnowplowMiniCookie'
});
var num=2;
function google(){
snowplow('trackStructEvent', 'Link', 'Clicked', 'Google', '', '1');
}
function ad(){
snowplow('trackSelfDescribingEvent', {
'schema': 'api/schemas/com.acme/ad_click/jsonschema/1-0-0',
'data':{
'targetUrl': 'https://www.bing.com'}
})
};
</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>
Schema:
{
"$schema" : "http://iglucentral.com/schemas/com.snowplowanalytics.self-desc/schema/jsonschema/1-0-0#",
"description" : "Schema for an Acme Inc ad click event",
"self" : {
"vendor" : "com.acme",
"name" : "ad_click",
"format" : "jsonschema",
"version" : "1-0-0"
},
"type" : "object",
"properties" : {
"clickId" : {
"type" : "string"
},
"targetUrl" : {
"type" : "string",
"minLength" : 1
}
},
"required" : [ "targetUrl" ],
"additionalProperties" : false,
"metadata" : {
"location" : "/api/schemas/com.acme/ad_click/jsonschema/1-0-0",
"createdAt" : "03/12/2018 20:54:04",
"updatedAt" : "03/13/2018 14:11:02",
"permissions" : {
"read" : "public",
"write" : "none"
}
}
}