Skip to content

Instantly share code, notes, and snippets.

@fblundun
Last active May 31, 2016 08:18
Show Gist options
  • Save fblundun/4937e1b0a94cd295cb6a to your computer and use it in GitHub Desktop.
Save fblundun/4937e1b0a94cd295cb6a to your computer and use it in GitHub Desktop.
Detect Snowplow
var page = require('webpage').create();
var system = require('system');
if (system.args.length === 1) {
console.log('Usage: you must provide some URL to check');
phantom.exit();
}
page.open(system.args[1], function(status) {
var usesSnowplow;
var information;
if(status === "success") {
var answer = page.evaluate(function(){
return window.GlobalSnowplowNamespace !== undefined || window._snaq !== undefined;
});
usesSnowplow = answer;
information = usesSnowplow ? "YES" : "NO";
} else {
information = "UNKNOWN";
}
console.log(system.args[1] + " : " + information);
phantom.exit();
});
@fblundun
Copy link
Author

First install phantomJS.

Then run

➜  phantomjs forecast.js http://snowplowanalytics.com
http://snowplowanalytics.com : YES

Output is YES if the site does have Snowplow, NO if it doesn't, and UNKNOWN if the connection failed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment