Jump to:

23491 Posts in 18996 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » Google Analytics Problem

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 1147 Views
  • _Vince
    Community Member
    161 Posts

    Google Analytics Problem Link to this post

    I am trying to install the tracking script on a Silverstripe site so I can generate visitor stats for the site.

    It's easy enough to do, Google produces a script that you are supposed to copy and paste just before the closing </head> tag on the page (i.e. on the Page.ss file)

    NOW... the problem is that I can never get the script to sit in the right place.

    I'm using SS 2.4.5 and it is ALWAYS and automatically putting the include tags for the CSS files LAST.

    So I can never place Google's script next to the </head> tag and Google Analytics tells me that the tracking stuff is not installed. So I can't get Analytics happening.

    Very odd, this has never happened to me before and I've installed those tracking scripts in heaps of SS sites.

    What do I do now? Anybody? Please?

  • Invader_Zim
    Community Member
    141 Posts

    Re: Google Analytics Problem Link to this post

    Hi _Vince.

    You want to use the asynchronous version, right?
    ( described here )

    I used this some time ago before i switched to another tracking solution, but i placed it before my </body> tag instead without any problems.

    But anyway, maybe you could try this in your Page_Controller:

    public function init() {
    Requirements::insertHeadTags(" ... insert your tracking code here ...");


    (Edit: man i suck big time at formatting code in this forum! I wonder how to keep tabs... )

  • _Vince
    Community Member
    161 Posts

    Re: Google Analytics Problem Link to this post

    Ah, THAT did the trick, thanks heaps!

Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.