簡體   English   中英

WordPress:在插件中添加Google Analytics onClick($ content)

[英]Wordpress: Adding Google Analytics onClick in plugin ($content)

我想將此行添加到我的Wordpress插件中以跟蹤在Google Analytics(分析)中提交的表單:

onClick="ga('send', 'event', { eventCategory: 'Get Solutions', 
eventAction: 'Set    Reminder', eventLabel: 'Activated Reminder'});"

我是這樣實現的:

$content .= '<input type="submit" name="sch_submit" value="Set reminder"   
style="background:#1eaa2f" onClick="ga('send', 'event', { eventCategory: 'Get 
Solutions', eventAction: 'Set Reminder', eventLabel: 'Activated Reminder'});">

但是,我現在面臨以下錯誤。

´Parse error: syntax error, unexpected T_STRING in /home/test/public_html/
 wp-content/plugins/schedule-reminder/plugin.php on line 70´

因此,我想知道如何在插件代碼中使用Google Analytics(分析)跟蹤表單提交?

謝謝。

您將需要使用反斜杠對單引號進行轉義,否則,您將告訴PHP字符串到達​​末尾,而並非如此。

$content .= '<input type="submit" name="sch_submit" value="Set reminder"   
style="background:#1eaa2f" onClick="ga(\'send\', \'event\', { eventCategory: \'Get 
Solutions\', eventAction: \'Set Reminder\', eventLabel: \'Activated Reminder\'});">';

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM