简体   繁体   中英

Google Analytics Event Tracking in PHP not working

Hey as the ga tracking code is in the php output i can't seem to get it to function. Outside of php the tracking code works fine but i think as i am trying to use 3 types of '"' it may be causing an issue?

$prodqoutput = 
'<div class="container" style="margin-bottom: 50px;">
    <div class="col-sm-6 col-md-4">
    </div>
    <div class="col-sm-6 col-md-4">
        <img src="' . $llogo . '" style="width: 100%;"><br />
        <center><span>' . $lexcerpt . '</span></center>
        <a href="' . $laffil . '" target="_blank" onClick="ga(‘send’, ‘event’, ‘Card Image’, ‘'.$brand.'’, ‘'.$etitle.'’);">
            <button style="height: 50px;" type="button" class="btn btn-primary btn-lg btn-block">
                View More Products! <span class="glyphicon glyphicon-refresh"></span>
            </button>
        </a>
    </div>
    <div class="col-sm-6 col-md-4">
    </div>
</div>';

If anyone can help that would be amazing.

Thanks in advance.

Try changing this part of the code:

onClick="ga(\'send\', \'event\', \'Card Image\', \''.$brand.'\', \''.$etitle.'\');">

Use only " and ' and when needed (like in your example) you could scape prepending \\

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM