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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

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   1687 Views

Avatar
_Vince

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

Avatar
Invader_Zim

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() {
    parent::init();
    Requirements::insertHeadTags(" ... insert your tracking code here ...");
}

Cheers
Christian

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

Avatar
_Vince

Community Member, 165 Posts

4 June 2011 at 9:49am

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