Google Analytics event tracking with PHP in html_output -


i'm getting category database using php , want use inside google analytics event tracking code. problem events not being recorded in google analytics.

here code snippets project:

1)

$docs = array(); while ($row = mysql_fetch_assoc($result)) { $doc = array();     $doc['my_tel'] = $row['my_tel'];     $doc['my_category'] = $row['my_category'];  $docs[] = $doc;  }  mysql_free_result($result); 

2)

    <?php $html_output = ''; foreach ($docs &$d) {     $html_output .= '<div>' .      '<a href="tel:' . $d['my_tel'] . '" onclick="_gaq.push([\'_trackevent\', ' . $d['my_category'] . ', \'event action\', \'event label\']);"><img src="call.png" width="65px" height="35px" border="0"></a>' .                  '</div>'; } echo $html_output; ?> 

if have @ console of browser there might javascript error, because second parameter of _gaq.push not wrapped quotes.

try this:

<?php $html_output = ''; foreach ($docs &$d) {     $html_output .= '<div>' .      '<a href="tel:' . $d['my_tel'] . '" onclick="_gaq.push([\'_trackevent\', \'' . $d['my_category'] . '\', \'event action\', \'event label\']);"><img src="call.png" width="65px" height="35px" border="0"></a>' .                  '</div>'; } echo $html_output; ?> 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -