Getting custom variables to work with Google Analytics

May 11, 2011 at 10:19 PM

I’ve been playing with the Framework and I tried to add a Google Analytics to a Siliverlight Navigation Application. Quite straightforward:

  1. Create a new Navigation application in VS
  2. Open MainPage.xaml in Blend
  3. Drop the GoogleAnalytics behahior in LayoutRoot and set Web Property ID
  4. Drop Track Action on ContentFrame

Works like a charm.

Now I would like to set some page scope custom variables. According to documentation:

“Page scope custom variables will correspond to the Custom Properties collection of the TrackAction associated with a specific object on the page (like a button).”

So I defined a custom property in Blend by clicking on “…” next to Custom Properties (Collection).

I ran the application, inspecting the requests with Fiddler, and noticed that the custom properties were missing.

Here is what the Get request looks like:

GET http://www.google-analytics.com/__utm.gif?utmac=UA-XXXXXXXX-1&utmcc=__utma%3D0.31207549.1305120588.1305126794.1305132451.3%3B&utmwv=4.4wp7&utmn=952725098&utmcs=utf-8&utmul=en-us&utmsr=1422x788&utmsc=32-bit&utmdt=SLNavApplication&utmp=/SLNavApplicationTestPage.aspx/About&utmhn=localhost&utmr=- HTTP/1.1

 Here is my Xaml:

           		<i:EventTrigger EventName="Navigated">
            			<mwab:TrackAction>
            				<mwab:TrackAction.CustomProperties>
            					<mwad:PropertyValue PropertyName="MyVariable" Value="MyValue"/>
            				</mwab:TrackAction.CustomProperties>
            			</mwab:TrackAction>
            		</i:EventTrigger>

How do I get custom variables to work?


May 11, 2011 at 10:20 PM

As a sidenote, I've downloaded the Framework's source code to try and investigate the problem, but it does not appear to contain the source for Google.WebAnalytics.dll

Is the source for that DLL available somewhere?

Thanks,

David.

May 12, 2011 at 5:58 PM

Looked at Google.WebAnalytics with Reflector - looks like there is a bug in AppendCommonParameters() method called from BuildUrl():

it only appends custom variables if the event type is not PageView. This looks plain wrong because Google Analytics supports page scope custom variables.

Am I understanding the issue correctly? If yes, is there a chance to get a bugfix for this?

Thanks,

David.

Oct 13, 2011 at 6:37 PM

David

Have you ever got the CustomProperties work ? Please let me know. I'm having the same issue.

Thanks

Oct 20, 2011 at 5:02 PM

I have not had a chance to look at this again.

I have filed a bug on it, though: http://msaf.codeplex.com/workitem/15864

David

Jan 5 at 6:07 AM