Created
June 28, 2012 14:40
-
-
Save ralt/3011728 to your computer and use it in GitHub Desktop.
A little script that will screw up people using campaigns on Google Analytics
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A little script that will screw up people using campaigns on Google | |
* Analytics. | |
* | |
* Do. Not. Use. | |
* | |
* I am not responsible for any action that people may employ using this | |
* little script. It was done purely out of curiosity. | |
* | |
* Usage: | |
* node shitanal.js url | |
* | |
* Example: | |
* node shitanal.js http://www.google.com/search | |
*/ | |
var http = require( 'http' ); | |
// Generate a random string of 10 characters | |
function randomString() { | |
var text = '', | |
possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz', | |
len = possible.length; | |
for ( var i = 0; i < 10; i++ ) { | |
text += possible.charAt( Math.floor( Math.random() * len ) ); | |
} | |
return text; | |
} | |
( function req() { | |
// Generate the path | |
var path = process.argv[ 2 ] + | |
'?utm_source=' + randomString() + | |
'&utm_medium=' + randomString() + | |
'&utm_campaign=' + randomString(); | |
http.get( path, function( res ) { | |
if ( res.statusCode === 200 ) { | |
console.log( 'Hit successfully: ' + path ); | |
req(); | |
} | |
else { | |
console.log( 'Error. Stopping the script.' ); | |
} | |
} ); | |
} () ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment