事件跟踪标签等于输入字段值

Event tracking label to equal input field value

我有一个网站,上面嵌入了 google 地图,与 https://developers.google.com/maps/documentation/javascript/examples/places-autocomplete 类似,但显示了我们的办公室。

我正在尝试使用 google 分析设置事件跟踪,并希望使用地图跟踪用户。我希望标签是在搜索字段中输入的值,例如

<input type=”submit” onClick=”_gaq.push([‘_trackEvent('Search-form', 'Submit', 'London', 10]);” />

但 'London' = 用户输入的内容。

这可能吗?

是的,这是可能的。您只需要添加一些代码来获取为该特定字段输入的值并将其填充到标签参数中。如果您的城市输入字段具有特定 ID,那么您可以执行类似

的操作
_gaq.push(["_trackEvent", "category", "action", $("#city").val(), 10]);