Google Analytics for SharePoint 2013 / Office 365

This has been replaced by Plain365 which provides an easy installation.
Download and Video – Obsolete
The solution is based on the Google Analytics solution for SharePoint 2010. It enables on all pages the Google Analytics code or some other JavaScript without modifying the underlying master pages or any other file delivered from Microsoft. The solution runs as a non-code sandbox solution. That should limit deployment difficulties.
The solution works with SharePoint 2010 and 2013.
Why this is not an App? Because nobody uses them.
  1. Open your SharePoint 2013 site collection or your public website
  2. Rename the URL in the browser (Login as needed with a site collection administrator / your admin account):Current URL:
    Rename to:
    Somehow Microsoft has removed the possibility to show the sandbox solutions folder from the UI in public websites. Anyway as they are using it for design packages and website templates, I assume there will be no difficulties with no-code sandbox solutions.
  3. Select Upload Solution
  4. Select Browse…
  5. Download the solution package, extract it and upload the wsp file:
  6. Click Open and OK to upload the solution
  7. Select Activate to install the solution
  8. Now, verify the activation was successfully
  9. Finally you have to add your Google Analytics code. For that you can open Site Settings:
  10. There is a new menu entry point under Site Collection Administration which is called Google Analytics
  11. Paste the google analytics code into the red square and press OK. That’s it.

To test if it works as expected, just open the website in a different browser and take a look on the html source. If your Google Analytics code is there, then everything is fine.

If you are unhappy with the solution, then just deactivate the sandbox solution over the same URL. As there is no modification on existing sites done, your site will work as before.


  • Martin

    Hi, love the simplicity of this solution – thanks for making it available! I’ve implemented it on some of my site collections to evaluate it, and the beauty of it is that all pages on all sub sites use the tracking code and get tracked in GA.

    However, since GA has some scalability limitations (the tracking ID is at the Property level, i.e.. the Site Collection level, and you have a max. of 25 Views per Property (so, 25 sub sites can be filtered) I’m limited to not being able to filter on all my sites in a site collection.

    So, I’ve been looking into using Tag Manager instead, as a wrapper for the tracking IDs at the Site Collection level, and implementing it in the same way – ie. using your solution in the Site Collection features. This would in theory allow me to add Tags on each of the sub sites which I can setup with unique UA- numbers.

    But! When I try to add the GTM code to your solution in Site Collection Admin, it won’t take… I remove the references, but can’t get the code to stick in the box – it’s empty when I save it and open it again…

    Does your solution allow the placing of GA tracking ID only? (and not the GTM wrapper code?)

    If so, do you know of any way I could get the GTM wrapper code applied at the Site Collection level? Or, a way of implementing different tracking IDs for various Properties for sites in the same Site Collection, using your method?

    Thanks for any help and advice you can offer.

    • fiechter

      It might be possible to add an additional action containing the TagManager.
      Can you give me a more detailed example?

  • Martin

    Hi Adrian, as mentioned, with the tracking ID applied at the GA Property level, it allows just 25 different Views (meaning that it’s possible to filter on 25 sites in a site collection, say).

    I reckon if the Tag Manager container code was inserted into the master page in the way you do with the GA code (as a solution at the site collection level) it would enable more scalability, since you can insert unlimited tags for pages into the container.

  • Luke Greening

    Awesome, saved me having to update each of my Master pages manually for each SC.

    Good man, top marks.

  • Waz

    Hi Adrian, Its a wonderful post. Thanks a lot for making our life easier. Just a quick question, We have a requirement where we want to have different tracking code for subsites. I don’t seem to see an option to add different code for subsites in sharepoint 2013 with your solution. Please advise!

  • Luke

    Hi Adrian,

    Does this allow the WOPI pages to be tracked, i.e if a document tis opened in the browser, we have a need to track documents being opened and how often, really want to use GA if possible for this. Someone mentioned this solution could do that but I did this back in July last year and can’t see that it does this?

    Many thanks

    • fiechter

      no, Office Web Apps are not tracked. You have different options to get some information about WOPI pages.
      The built-in option is to activate read auditing on your SharePoint Online site.

  • Sami Hamed

    Hi Adrian,

    is it possible to use the Tag Manager instead the tracking ID?


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.