Skip to content

Instantly share code, notes, and snippets.

@duncanmorris
Last active August 29, 2015 14:18
Show Gist options
  • Save duncanmorris/70fb2ec4d0180aa7b504 to your computer and use it in GitHub Desktop.
Save duncanmorris/70fb2ec4d0180aa7b504 to your computer and use it in GitHub Desktop.
Using PhantomJS to monitor Google Analytics - example 1
var page = require('webpage').create();
var url = 'http://crawlbin.com/response_301/';
console.log('Loading: ' + url);
page.open(url, function (status) {
//Page is loaded!
if (url != page.url){
console.log('Redirected: ' + page.url)
}
phantom.exit();
});
@duncanmorris
Copy link
Author

Usage: phantomjs example1.js

Output:
Loading: http://crawlbin.com/response_301/
Redirected: http://crawlbin.com/

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