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?