This project is read-only.
Project Description
Integrates google analytics into silverlight application.

Please note that only new Asynchronous Tracking Code is supported.

Usage:

1. Add google analytics tracking code into silverlight hosting page (see http://support.google.com/googleanalytics/bin/answer.py?hl=en&answer=174090 for details).

2. download latest release and add reference to FTG.Silverlight.Google.Analytics.dll into your silverlight project, Alternately add reference via nuget (http://nuget.org/packages/SGA).

3. Code sample

using FTG.Silverlight.Google.Analytics;
...

//track page
Tracker.TrackPage("mypage");

//track event
Tracker.TrackEvent("MyCategory", "MyAction");

//track event with label
Tracker.TrackEvent("MyCategory", "MyAction", "MyLabel");

Track supported silverlight version

To track supported silverlight version use SilverlightUtils.js.

SilverlightUtils.getInstalledSilverlightVersion() function will return major and minor silverlight version
as string (for example "4.0") or null if client doesn't have silverlight or turned it off in browser.

The following example shows how to use custom variable to track supported silverlight version:

    <script type="text/javascript" src="Silverlight.js"></script>
    <script type="text/javascript" src="SilverlightUtils.js"></script>
    <script type="text/javascript">

        var slv = SilverlightUtils.getInstalledSilverlightVersion();
        slv = slv == null ? "Not supported" : slv;

        var _gaq = _gaq || [];
        _gaq.push(['_setAccount', 'UA-XXXXXXXXX']);
        _gaq.push(['_setDomainName', 'www.your-domain-name.com']);
        _gaq.push(['_setCustomVar', 1, 'SilverlightVersion', slv, 2]);
        _gaq.push(['_trackPageview']);

        (function () {
            var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
            ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
            var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
        })();

    </script>


Last edited Apr 23, 2012 at 11:15 PM by phnix19843, version 3