Slight improvement Google Analytics

This is a forum to suggest new features for mojoPortal. 

This thread is closed to new posts. You must sign in to post in the forums.
3/16/2010 11:15:00 AM
Gravatar
Total Posts 171
I am a Russian programmer

Re: Slight improvement Google Analytics

Thank you, Joe

If the quotes are not available, then get an error in IE in ga.js. You can try it.

and more

There is another useful function_addOrganic

http://code.google.com/intl/ru-RU/apis/analytics/docs/gaJS/gaJSApiSearchEngines.html#_gat.GA_Tracker_._addOrganic

Can you add it?

Best regards, Alexander

3/16/2010 12:54:34 PM
Gravatar
Total Posts 18439

Re: Slight improvement Google Analytics

Hi Alexander,

I get no script errors in IE 8 when I try using an overridedomain and sethash = false. I suspect it has something to do with either browser settings for script debugging or with hosting the ga.js file yourself. I believe the code is correct without quotes and would be incorrect with them.

Maybe I will look into adding the _addOrganic at some point but not now as I've already spent way more time on Google Analytics this week than planned and other things I need to do have not been accomplished. 

Since _addOrganic could be called multiple times for multiple additional search engines, it does not seem like an easy thing to add. You can just as easily add javascript to the page/layout.master yourself to accomplish this, especially with the new async version, you can add a script block of your own that does

_gaq.push(['_add_Organic','somesearchengine.com', 'somekeyword', false]);

Best,

Joe

3/16/2010 1:03:27 PM
Gravatar
Total Posts 171
I am a Russian programmer

Re: Slight improvement Google Analytics

Hi, Joe

You can just as easily add javascript to the page/layout.master yourself to accomplish this, especially with the new async version, you can add a script block of your own that does

_gaq.push(['_add_Organic','somesearchengine.com', 'somekeyword', false]);

I'll go that way

Best regards, Alexander

3/17/2010 10:56:26 AM
Gravatar
Total Posts 171
I am a Russian programmer

Re: Slight improvement Google Analytics

Hi, Joe

Fix:

1) delete mojoGoogleAnalyticsScript.cs from Web\Controls

For GoogleAnalyticsScript.cs :

2) script.Append("} catch(err) {}");
be called after _trackPageview();

3) SetupUserTracking(script);

must be called before _trackPageview();

Best regards, Alexander

3/17/2010 11:12:08 AM
Gravatar
Total Posts 171
I am a Russian programmer

Re: Slight improvement Google Analytics

and more

script.Append(trackerName + "._setCustomVar(1, \"" + memberLabel + "\", \"" + memberType + "\", 1);");
to

script.Append(trackerName + "._setCustomVar(1, \"" + memberType + "\", \"" + memberLabel + "\", 1);");
 

Best regards, Alexander

3/18/2010 11:21:55 AM
Gravatar
Total Posts 171
I am a Russian programmer

Re: Slight improvement Google Analytics

Hi, Joe

I have a small question. Why do you separate the code try{} catch(err) {} in two parts?

I have not seen that would have been done in the examples, and as far as I know try{} catch(err) {} has a large overhead.

And more

The code if(_gat != undefined) was needed in older versions of the Google Analytics, but now it is superfluous.

Best regards, Alexander

P.S. Now I'm testing Asynchronous tracking....

3/18/2010 1:58:29 PM
Gravatar
Total Posts 171
I am a Russian programmer

Re: Slight improvement Google Analytics

mistake in Asynchronous tracking

AnalyticsAsyncTopScript.cs

place

SetupUserTracking(writer);

before

if (pageToTrack.Length > 0)
{
writer.Write(" _gaq.push(['_trackPageview','" + pageToTrack.Replace("'", string.Empty).Replace("\"", string.Empty) + "']); ");
}
else
{
writer.Write(" _gaq.push(['_trackPageview']); ");
}

 

and change SetupUserTracking(HtmlTextWriter writer) to

if (string.IsNullOrEmpty(memberLabel)) { return; }

writer.Write("_gaq.push(['_setCustomVar', 1, '" + memberType + "', '" + memberLabel + "', 1]);");
writer.Write("\n");


AnalyticsAsyncBottomScript.cs

place

if (WebConfigSettings.GoogleAnalyticsScriptOverrideUrl.Length > 0)
{
OverrideScriptUrl = WebConfigSettings.GoogleAnalyticsScriptOverrideUrl;
}

before

// let Web.config setting trump site settings. this meets my needs where I want to track the demo site but am letting people login as admin
// this way if the remove or change it in site settings it still uses my profile id

and

change

writer.Write("ga.src = '" + overrideScriptUrl + ":';");

to

writer.Write("ga.src = '" + overrideScriptUrl + "';");

Best regards, Alexander

3/19/2010 3:20:29 AM
Gravatar
Total Posts 171
I am a Russian programmer

Re: Slight improvement Google Analytics

Thank you, Joe

I examined all parts of the code and everything is working correctly, except for one piece of code

AnalyticsAsyncTopScript.cs

add quote after _setCustomVar

writer.Write("_gaq.push(['_setCustomVar', 1, '" + memberType + "', '" + memberLabel + "', 1]);");
 

Excellent work, Joe! Congratulations!

Best regards, Alexander

3/20/2010 7:10:21 AM
Gravatar
Total Posts 18439

Re: Slight improvement Google Analytics

Hi Alexander,

Thanks for your help in testing the new async controls and finding my mistakes.

Best,

Joe

You must sign in to post in the forums. This thread is closed to new posts.