TagPlanet / yii-analytics-ga

A Google Analytics component for the Yii framework. This is for the current version of Google Analytics (ga.js)
MIT License
14 stars 2 forks source link

Event Handlers #10

Open srakl opened 9 years ago

srakl commented 9 years ago

in my view, i added this

<a href="#" onclick="<?php echo Yii::app()->googleAnalytics->_setCustomVar(1, 'Section', 'Life & Style', 3); ?>"click</a>

but it echo's 1 what am i doing wrong? Thanks

MisterPhilip commented 9 years ago

This plugin isn't meant for onclicks. Yii::app()->googleAnalytics->_setCustomVar(1, 'Section', 'Life & Style', 3); would set it in the global code and not return GA code.

srakl commented 9 years ago

you mean like this? in my controller? This doesn't work for me

public function actionAjaxGetnumber($id) {
        if (Yii::app ()->request->isAjaxRequest) {

            Yii::app()->googleAnalytics->_trackEvent($_GET['type'], "Number", $id);
                 }

sorry need help, kind of new to yii