Created
June 22, 2011 22:05
-
-
Save pierceray/1041363 to your computer and use it in GitHub Desktop.
determining the GA code based on params or lack there of
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
//lookup object | |
var gaKeys = { | |
'tdshs_ems': { | |
'01': 'UA-234234-23', | |
'02': 'UA-234234-24', | |
'error': 'bad error' | |
}, | |
'error' : 'UA-bad-code' | |
}; | |
var agencyName = 'TDSHS'; //error condition is 'error' | |
var configId = 'TDSHS_EMS'; //error condition is 'error' | |
var licenseId = 01; //other values are 2 digit numbers and 'error' | |
var page = 'welcome' //other value 'elgibility', 'guidelines', 'null' | |
agencyName.toLowerCase(); | |
if ((agencyName == "null") || (agencyName == "")) { | |
agencyName = "error"; | |
} | |
configId = configId.toLowerCase(); | |
if ((configId == "null") || (configId == "")) { | |
configId = "error"; | |
} | |
if ((licenseId == "null") || (licenseId == "")) { | |
licenseId = "error"; | |
} | |
if (page != "null") { | |
page = 'elgibility'; //values could be 'elgibility' and 'guidelines' | |
} else { | |
page = "welcome"; | |
} | |
var theKey = gaKeys[configId][licenseId]; | |
var _gaq = _gaq || []; | |
_gaq.push(['_setAccount', gaKeys[configId][licenseId]]); | |
_gaq.push(['_trackPageview']); | |
_gaq.push(['_trackPageLoadTime']); | |
_gaq.push(['_setLocalRemoteServerMode']); | |
(function() { | |
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; | |
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; | |
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment