Google Analytics plugin manually set domain


Is it possible to manually set the domain using this plugin?

We require tracking across multiple subdomains, so we need to set the domain to be at a higher level as per google's requirements (

For example the site is, so we need to set it to so users are tracked across all sites.

There is an option in the admin tool for 'One domain with multiple subdomain' - but this sets the domain to the full host.

Apr 10, 2014 17:16

Hi Sam, 

Have you had a chance to look at the user guide for GA ?

Hope it helps. 

Apr 23, 2014 14:02

Hi Shahid,

Thanks for getting back to me. No I hadn't seen that guide, does it relate to both CMS6R2 and 7? In any case the domain wasn't altered in either my local or our test environment so I wrote my own method and which did a find and replace:

        public static void GenerateEpiGoogleAnalytics(this PageBase page, HttpContext context)

            string existingDomain = UriSupport.SiteUrl.Host.ToString();
            string gaDomain = SiteSettings.GlobalHomePage.GoogleAnalyticsDomain;

            ScriptBuilder scriptBuilder = new ScriptBuilder();
            if (!scriptBuilder.ShouldAppendScript((HttpContextBase)new HttpContextWrapper(context)))
            bool requiresScriptReference;
            string str = scriptBuilder.BuildTrackingScript(out requiresScriptReference, (HttpContextBase)new HttpContextWrapper(context), page.CurrentPage);

            str = str.Replace(existingDomain, gaDomain);
            page.Page.ClientScript.RegisterStartupScript(typeof(ScriptAppender), "CustomEpiGoogleAnalytics", str, true);
            if (requiresScriptReference)
                string webResourceUrl = page.Page.ClientScript.GetWebResourceUrl(typeof(ScriptAppender), "EPiServer.GoogleAnalytics.Scripts.Tracking.js");
                page.Page.ClientScript.RegisterClientScriptInclude("EpiGat", webResourceUrl);


Apr 28, 2014 17:28
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.