This project is read-only.

How to use this code

1. Add reference to this library either by installing via Nuget Install-Package w8ga or by downloading from "Downloads" tab
2. Add following code to your App.xaml

            <a:GoogleAnalyticsSettings x:Key="GoogleAnalytics" WebPropertyId="UA-11111111-2" />

3. Set correct WebPropertyId value. This is your resource id in Google Analytics (Should be similar to UA-12123123-3)

4. Wherever you call Window.Current.Activate(), call AnalyticsHelper.Setup() just before, see comments in UPPER CASE

protected override void OnLaunched(LaunchActivatedEventArgs args)
//INSERT AnalyticsHelper.Setup() just before calling Window.Current.Activate()

5. For supporting search contract (and other activation scenarios), follow step 4 - just use AnalyticsHelper.Setup(). If you have single place where you create Application root frame, you can call AnalyticsHelper.Setup() just after creating the frame. See example code below (or sample app in the source code tab)

        private static Frame CreateApplicationFrame()
            var rootFrame = new Frame();
//For example you can subscribe to Navigated event 
            rootFrame.Navigated += rootFrame_Navigated;
            return rootFrame;

// and track pageviews in single place.
        static void rootFrame_Navigated(object sender, NavigationEventArgs e)
            if (e.Uri == null)
                if (e.SourcePageType != null)
                    string uri = "/" + e.SourcePageType.FullName;

6. Add blank.html page to your Application project (the one that is built into a package).
This is as easy as 1-2-3. Add new item -> HTML page.
Make sure it's placed in the root of the project and name is exactly blank.html


7. Ensure that your app defines capability "Internet (Client)". Open Package.appxmanifest and check capabilities tab


8. Profit! Run your app and see pageviews in realtime section in Google Analytics control panel:


Last edited Nov 26, 2012 at 1:10 AM by AlexSorokoletov, version 8


SaranMalliga May 2, 2014 at 10:41 AM 
I have integrated w8ga 2.5 in windows 8 app xaml c#, but still no records found in my google analytics reports. Can any one please suggest me whether w8ga 2.5 will work in windows app.

And also i have tried with w8ga 2.0, but i am getting this error 'DT.GoogleAnalytics.Metro\Themes\generic.xaml' does not exist.'. Please suggest me to integrater GA in win 8 app.

anjue May 2, 2013 at 1:13 PM 

This works in VS 2012 ultimate with silverlight and c#, i tried and works.
It takes only a few minutes for me to get my data in the Google Analytics page.
Be sure that you give a valid WebPropertyID in App.xaml

anjue May 2, 2013 at 1:03 PM 
This will work only if u add the project downloaded from the step-1 in ur app and refer it. Add the code above in App.xaml.cs and if u want google analytics to work in other pages, add the code below :
var ver = Windows.ApplicationModel.Package.Current.Id.Version;
var appVersion = ver.Major + "." + ver.Minor + "." + ver.Build + "." + ver.Revision;
//appVersion gives you the version of ur app
string pageUrl = "GAME_SS_" + appVersion.ToString() + "_" + CultureInfo.CurrentCulture.Name + "Win8";
You can give whatever string u want in pageUrl which lets u identify the page of ur app and this url will be displayed in the Google Analytics page.

victorhggqvst Dec 23, 2012 at 12:05 AM 
In all regular web experience I have with Google Analytics it is always about a day until stats show up. I don't see why this method should give any faster results. Can you tell? otherwise you should change this in the tutorial.

jinishans Dec 11, 2012 at 3:09 AM 
Is it possible to use this in a Win 8 WinJS/HTML 5 App ? If so, pls let us know how. The 'how to' talks only about xaml WinRT app.

preishuberhannes Dec 1, 2012 at 10:54 AM 
have the Nov bits, and the sample. But I do not get live results (yes have created the app id WebPropertyId="UA-36681694-1") I see fiddler catching the analytics traffic
How I can troubleshoot or what can be the issue

mandeepghotra Nov 7, 2012 at 11:27 AM 
Hi All,

I have implemented the above step by step and did not get any type of error.
Can anybody please help me display the Google Analytics on tiles and apps.

Thanks in advance

rkshnair Oct 11, 2012 at 7:52 AM 
I am also facing the same issue what explained above. In my application i facing issues when loading the application, suspending the application etc. Can you please guide me to resolve this issue.

patrikc Sep 27, 2012 at 1:28 PM 
I experience the same problem with "Error HRESULT E_FAIL has been returned from a call to a COM component.".

The solution builds but I have problem with that it hangs on startup.
On this line: MetroApplicationServiceBase.Instance.ApplicationLaunched(args);

Mnemonic2k Sep 11, 2012 at 12:58 PM 
I have the same problem since WIndows 8 RTM

Qua Aug 29, 2012 at 4:43 PM 
I am experiencing the same failure as above.

garth_whitaker Aug 16, 2012 at 9:09 AM 

I have been searching long and hard for a analytics tool for metro apps so big ups for taking the time to make this happen. I just tried testing this package but I get this error :
"Error HRESULT E_FAIL has been returned from a call to a COM component."
When I add <a:MetroApplicationServiceBase x:Key="GoogleAnalytics" WebPropertyId="UA-12123123-3" /> in my app.xml.

Can you lead me in the right direction to resolve this?