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.

Customising the CMS /

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

Add Google Analytics on Page Comment post


Go to End


1424 Views

Avatar
MarijnKampf

Community Member, 176 Posts

9 March 2010 at 11:29pm

I would like to track addition of page comments in Google Analytics. I hoped it would be easy to do this by extending the PageComment class onAfterWrite function. However, I can't find a way to include the Google Analytics JS and get it executed.

PageCommentGoogleAnalyticsWrite.php

class PageCommentGoogleAnalytics extends DataObjectDecorator {
  function onAfterWrite() {
   	parent::onAfterWrite();
	return $this->owner->renderWith("PageCommentGoogleAnalyticsWrite");
   }
}

PageCommentGoogleAnalyticsWrite.ss

<script>
alert("PageCommentGoogleAnalyticsWrite");
</script>

Anyone any tips on how to track posting of comments in Google Analytics?