Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

General Questions /

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

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

Google Analytics Problem

Go to End

3 Posts   1630 Views


Community Member, 165 Posts

3 June 2011 at 5:44pm

Edited: 03/06/2011 5:45pm

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 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?


Community Member, 141 Posts

4 June 2011 at 1:22am

Edited: 04/06/2011 1:27am

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... :-( )


Community Member, 165 Posts

4 June 2011 at 9:49am

Ah, THAT did the trick, thanks heaps! :)