Try our conversational search powered by Generative AI!

Configuring GA for EPiServer 7 when using MVC?

Vote:
 

Hi 

We are using MVC4 on our EPiServer 7 CMS project and want to add the Google Analytics plugin.

However, as the plugin documentation mentions only the web forms implementation, I am wondering how we output the GA Script when using _Layout.cshtml and Razor syntax.

 

Is it possible for us to use the GA Plugin with MVC and Razor syntax?

 

Martin Graney

 

#71868
May 30, 2013 17:50
Vote:
 

If you are using the GA plugin from the EPiServer Add-Ons, you actually only need this in the bottom of the layout:

@Html.Raw(Html.RequiredClientResources("Footer"))

   

Optionally, you could manually get the GA script using this:

@Html.AnalyticsTrackingScript(currentPage)

    

If you look at the developer guide for the GA module for CMS 6 R2, they briefly mention how to use it in MVC:

http://world.episerver.com/Documentation/Items/Developers-Guide/Google-Analytics-for-EPiServer/Developers-Guide---EPiServer-Google-Analytics-Beta---CMS-6-R2/

#71871
Edited, May 31, 2013 5:20
Vote:
 

Thanks Chris. 

I missed that line when I read through the documentation.

#71893
May 31, 2013 12:36
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.