Skip to content

Instantly share code, notes, and snippets.

@saikat
Created June 20, 2011 19:13
Show Gist options
  • Save saikat/1036334 to your computer and use it in GitHub Desktop.
Save saikat/1036334 to your computer and use it in GitHub Desktop.
function trackGAPageView(page)
{
if (typeof(gaq) != "undefined" && _gaq)
{
_gaq.push(['_trackPageView', page]);
}
};
function trackMPEvent(event, extraInfo)
{
try {
if (typeof(mpq) != "undefined" && mpq)
{
if (!extraInfo)
extraInfo = {};
extraInfo.version = MOCKINGBIRD_VERSION;
if (typeof window != "undefined" && typeof window.navigator != "undefined")
{
var userAgent = window.navigator.userAgent;
var theBrowser = "Unknown";
if (userAgent.indexOf('Chrome') != -1)
theBrowser = "Chrome";
else if (userAgent.indexOf('Firefox') != -1)
theBrowser = "Firefox";
else if (userAgent.indexOf('Safari') != -1)
theBrowser = "Safari";
extraInfo.browserName = theBrowser;
}
extraInfo.loggedIn = ([[MBUserSessionManager defaultManager] userDisplayName] !== nil);
extraInfo.project = [[DocumentInstance document] projectHash];
mpq.push(["track", event, extraInfo]);
}
} catch (ex) { }
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment