Skip to content

Instantly share code, notes, and snippets.

@hakanilter
Last active March 2, 2018 14:10
Show Gist options
  • Save hakanilter/f444aedd682cf95dfdfc35101e17bc4a to your computer and use it in GitHub Desktop.
Save hakanilter/f444aedd682cf95dfdfc35101e17bc4a to your computer and use it in GitHub Desktop.
/*
* PyroCollector : Clickstream Collector Client
* (c)2018 DataPyro.com
*/
// set your endpoint
var endPoint = "https://d1q9rxqnug6ou7.cloudfront.net/public/blank.gif?";
// collector
var pyroCollector = {
collect: function(obj) {
if (typeof(obj) !== undefined) {
var json = encodeURI(JSON.stringify(obj));
var img = document.createElement("img");
img.src = endPoint + "_t=" + new Date().getTime() + "&json=" + json;
document.body.appendChild(img);
}
}
};
// collect an object
if (typeof(dataLayer) !== undefined && dataLayer.length > 0) {
var layers = dataLayer.filter(function(o) { return o['sessionId'] !== undefined; });
if (layers.length > 0) {
pyroCollector.collect(layers[0]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment