Created
May 4, 2011 21:23
-
-
Save purplecabbage/956066 to your computer and use it in GitHub Desktop.
GoogleAnalyticsPhoneGapPlugin
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
<script type="text/javascript" charset="utf-8" src="GoogleAnalyticsPlugin.js"></script> | |
<script type="text/javascript" charset="utf-8"> | |
var googleAnalytics; | |
function onBodyLoad() | |
{ | |
document.addEventListener("deviceready",onDeviceReady,false); | |
} | |
/* When this function is called, PhoneGap has been initialized and is ready to roll */ | |
function onDeviceReady() | |
{ | |
// do your thing! | |
googleAnalytics = window.plugins.googleAnalyticsPlugin; | |
googleAnalytics.startTrackerWithAccountID("UA-YOURCODEHERE"); | |
googleAnalytics.trackPageview("/application/launch"); | |
} | |
// example of tracking an event in your app | |
googleAnalytics.trackEvent("Videos","Play","Take On Me: Literal Video Version",1); | |
</script> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment