Issues Google Event Tracking and PHP " & '

cstormer
cstormer used Ask the Experts™
on
I have code like this:

$returnString.='<a href="'.getUrl($value['fk_category_id'], 'category').'" title="'.$value['menu_item_label'].' Products" onClick="_gaq.push(["_trackEvent", "Menu", "Left", "'.$value['menu_item_label'].'"]);">'.$value['menu_item_label'].'</a>';

Open in new window


but I need it to be

$returnString.='<a href="'.getUrl($value['fk_category_id'], 'category').'" title="'.$value['menu_item_label'].' Products" onClick="_gaq.push(['_trackEvent', 'Menu', 'Left', ''.$value['menu_item_label'].'']);">'.$value['menu_item_label'].'</a>';

Open in new window


Basically the " I have in mine should be '

The example gives is: <a onclick="_gaq.push(['_trackEvent', 'category', 'action', 'opt_label', opt_value]);">click me</a>

Any suggestions on how to code this correctly..
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
Just escape single quote with \

$returnString.='<a href="'.getUrl($value['fk_category_id'], 'category').'" title="'.$value['menu_item_label'].' Products" onClick="_gaq.push([\'_trackEvent\', \'Menu\', \'Left\', ''.$value['menu_item_label'].'']);">'.$value['menu_item_label'].'</a>';

Open in new window

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial