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.

General Questions /

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

Google Analytics Problem


Reply


3 Posts   1232 Views

Avatar
_Vince

Community Member, 162 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?
([url=http://www.google.com/support/googleanalytics/bin/answer.py?answer=55488&utm_source=DiscoverList&utm_medium=et&utm_campaign=en_us&hl=en] described here [/url])

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, 162 Posts

4 June 2011 at 9:49am

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