简体   繁体   English

Google跟踪代码管理器-如何将字段设置为Google Analytics(分析)?

[英]Google tag manager - How can I push the Fields to set into Google Analytics?

Im trying to: 我试图:

See what Search Queries in my Site search gives the visitor 0 search results. 查看“我的网站”搜索中的哪些搜索查询可为访问者提供0个搜索结果。

This is what I get from the Site search tag: 这是我从“网站”搜索标记中获得的:

 Event Action 'Submit search' Event Category 'Search' Event Label 0 Fields to Set {page: '/sok?q=helloworld', anonymizeIp: 'true'} 

What I want in Google Analytics is to see what Search query (in this case "helloworld") gave me Event label 0. 我想要在Google Analytics(分析)中看到的是什么搜索查询(在本例中为“ helloworld”)为我提供了事件标签0。

One issue you'll have to figure out is, "How are you doing to determine that there were 0 search results returned?" 您必须弄清的一个问题是,“如何确定返回的搜索结果为0?” since you only want to fire the event when there are no results. 因为您只想在没有结果时触发该事件。 Are you going to scrape the page, or will you set up a listener, or will you do a dataLayer push (I recommend the last method)? 您是要抓取页面还是要设置侦听器,还是要进行dataLayer推送(我建议使用最后一种方法)?

If you do a dataLayer push, then you'll have to also push an event 如果执行dataLayer推送,则还必须推送event

dataLayer.push({
   'event': 'search results',
   'numResults': 0
})

Once you have that in place, then you would need to create a URL type variable with the Query component type set with the Query key of q . 将其放置到位后,您将需要创建一个URL类型变量,并使用Query keyq设置Query组件类型。 Also create other associated variables, like numResults . 还创建其他关联变量,例如numResults

Then in your event tag, you can set the page field with that GTM variable, do your other settings, and then fire the tag on the search results event and when numResults = 0 , all pushed from the dataLayer. 然后,在事件代码中,您可以使用该GTM变量设置page字段,进行其他设置,然后在search results事件上触发代码,并且当numResults = 0 ,全部从dataLayer推送。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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