Google分析(通过代码管理器)在第一次网页加载后会丢失对访问者的跟踪

时间:2022-01-15 15:19:48

I am experiencing a very strange problem with Google tag manager (GTM), Google analytics (GA) and Google adwords. So far I am getting nowhere with solving it.

我在使用Google代码管理器(GTM),Google分析(GA)和Google adwords时遇到了一个非常奇怪的问题。到目前为止,我无法解决它。

The setup:
We have a singe page application (backbone and marionette) and we are using GTM to push virtual pageviews to GA using standard dataLayer.push events (and also e-commerce events if this is relevant). This setup generally works fine.

设置:我们有一个单页应用程序(骨干和牵线木偶),我们使用GTM使用标准dataLayer.push事件(如果相关,还有电子商务事件)将虚拟网页浏览推送到GA。此设置通常正常。

The problem:
The problem is users coming from adwords, with a gclid tag. The first pageview for these users is tracked and attributed do the adword campaign correctly, but as soon as they click any link on the site they seem to get a new session in GA, and the original session is then counted as a bounce. All pages are on the same domain, and we have verified that these campaign users are not actually bouncing, they are still on the site but are somehow mislabeled by GA.

问题:问题是用户来自adwords,带有gclid标签。跟踪这些用户的第一次网页浏览并正确归因于adword广告系列,但只要他们点击网站上的任何链接,他们似乎就会在GA中获得新会话,然后原始会话计为退回。所有网页都在同一个网域上,我们已经确认这些广告系列用户实际上没有弹跳,他们仍然在网站上,但在某种程度上被GA错误标记。

I.E.

  1. The user enters the site with a gclid tag from adwords.
  2. 用户使用adwords中的gclid标记进入网站。

  3. The visit is tracked as google cpc traffic.
  4. 该访问被跟踪为谷歌cpc流量。

  5. The user clicks a link in the page, or triggers backbones router.navigate function to load new content.
  6. 用户单击页面中的链接,或触发主干路由器.navigate功能以加载新内容。

  7. The original session from (2) is ended and counts as having bounced, even though the user just followed a link inside the site.
  8. 来自(2)的原始会话结束并计入已退回,即使用户只是跟随站点内的链接。

  9. A new session is created which is not counted as cpc-traffic (since the new page does not have the gclid tag).
  10. 创建一个新会话,不计入cpc-traffic(因为新页面没有gclid标记)。

Important note: This problem only occurs with campaign visitors! Users without a campaign tag don't get new sessions when they click links.

重要说明:此问题仅适用于广告系列访问者!没有广告系列标记的用户在点击链接时不会获得新会话。

Has anyone experienced a problem like this before? Is there any special things to take into account when using adwords via GTM on a single page app? What could cause Google analytics to lose track of a session like this?

以前有没有人遇到这样的问题?在单页应用上通过GTM使用adwords时是否有任何特殊事项需要考虑?什么可能导致谷歌分析失去这样的会议?

The site in question is https://fyndiq.se, in a mobile (it uses dynamic serving, the problem is not there on the desktop version which is not a SPA).

有问题的网站是https://fyndiq.se,在移动设备中(它使用动态服务,问题不在桌面版本上,而不是SPA)。


Edit - A summary of the problem and the current, imperfect, solution

编辑 - 问题摘要和当前不完善的解决方案

We have managed to get to an acceptable level with this, but it is far from perfect. Since the solution is all spread out in the comments I thought I would summarize the result here.

我们已经设法达到了可接受的水平,但它远非完美。由于解决方案全部在评论中展开,我认为我会在这里总结结果。

The problem is indeed that Analytics creates new sessions for Adwords users, losing track of the campaign. Analytics will start a new session for a user on a few different conditions. The most common are when the user has been inactive for 30 mins, when the user enters the site from a new campaign, and when the user enters the site from a known search engine.

问题确实是Google Analytics为Adwords用户创建了新会话,从而失去了对广告系列的跟踪。 Analytics将在几种不同条件下为用户启动新会话。最常见的情况是当用户处于非活动状态30分钟,用户从新广告系列进入网站时,以及用户从已知搜索引擎进入网站时。

The last two are the issue here. Google judges these condition based on the combination of campaign tags (gclid or utm_) and referrer, and on a single page application referrer does not update!

最后两个是这里的问题。 Google根据广告系列代码(gclid或utm_)和引荐来源的组合来判断这些条件,并且在单个页面上应用引用不会更新!

I.E.

  1. The users enters www.example.com via adwords. The analytics pageload will have a gclid campaign tag and google as a referrer.
  2. 用户通过adwords进入www.example.com。分析网页内容将包含gclid广告系列代码和Google作为引荐来源。

  3. The user clicks on an internal link and the SPA handles the routing.
  4. 用户单击内部链接,SPA处理路由。

  5. The campaign tag is removed and on a non SPA the referrer would change to www.example.com, but since this is a SPA there has been no real pageload and the referrer remains Google.
  6. 广告系列代码已移除,在非SPA上,引荐来源将更改为www.example.com,但由于这是SPA,因此没有真正的网页加载,而引荐来源仍为Google。

  7. Analytics gets the pageview, sees that the campaign and referrer combo has changed and that the referrer belongs to a search engine, and assumes the user left the page and then re-entered from a search term.
  8. Google Analytics获取综合浏览量,发现广告系列和引荐来源组合已更改且引荐来源属于搜索引擎,并假定用户离开了网页,然后从搜索字词中重新输入。

  9. Analytics starts a new session without the campaign and attributes the session as organic traffic (since it belives the user entered from a google search hit), and the campaign session is a bounce.
  10. Google Analytics(分析)会在没有广告系列的情况下启动新会话,并将会话定义为自定义流量(因为它相信从谷歌搜索匹配中输入的用户),并且广告系列会话是反弹的。

To prevent this we ended up doing two things. First we manually send a referrer to Google Tag Manager (if none is sent it defaults to document.referrer, which as said above does not update). On the first pageload we use the real referrer, so that hits get attributed correctly. On any subsequent pageload we send our own domain as referrer, like it would have been on a non SPA. This tells analytics that we are routing internallyand that it should not start a new session.

为了防止这种情况,我们最终做了两件事。首先,我们手动向Google跟踪代码管理器发送引荐来源(如果没有发送,则默认为document.referrer,如上所述,不会更新)。在第一个页面加载中,我们使用真正的引荐来源,以便正确地归属命中。在任何后续页面加载中,我们将自己的域名作为引荐来源发送,就像它在非SPA上一样。这告诉分析我们正在内部路由并且它不应该启动新会话。

The referrer can be sent to GTM the same way as you send a virtual pageview url and is (at the moment of writing) set in the same place as url and pagetitle. We make sure this is done on ALL events sent to analytics, not only the pageviews.

引用者可以像发送虚拟网页浏览网址一样发送给GTM,并且(在写作的那一刻)设置在与url和pagetitle相同的位置。我们确保在发送到分析的所有事件上完成此操作,而不仅仅是网页浏览。

The second thing comes from Jareds answer below, we make sure to set page and not just location (see below for why these are different). Page can be set in the advanced settings in GTM. Only one of these two things should be needed, but we did both just to be safe.

第二件事来自下面的Jareds答案,我们确保设置页面而不仅仅是位置(请参阅下面的原因,这些是不同的)。可以在GTM的高级设置中设置页面。只需要这两件事中的一件,但我们两件事都只是为了安全。

This seems to give us mostly correct data. We are still missing about 15% of the cpc transactions compared to the data from adwords but it's hard to know how close to done we really are. Adwords and analytics do not measure the same thing, so a diff is to be expected and the size of the diff will vary from page to page. It is however enough for us to use for testing and marketing, so it will have to do for now.

这似乎给了我们大部分正确的数据。与adwords的数据相比,我们仍然缺少大约15%的cpc交易,但我们很难知道我们到底有多接近。 Adwords和analytics不会测量同一个东西,因此可以预期差异,差异的大小会因页面而异。然而,对我们来说,它足以用于测试和营销,因此它现在必须要做。


If anyone finds a solution that is more consistent, please write a new answer!

如果有人发现更一致的解决方案,请写一个新的答案!

2 个解决方案

#1


We at betabrand.com are having very similar troubles.

我们betabrand.com遇到了非常类似的麻烦。

Last month we switched from a multipage to a single page app using angularJs and immediately starting getting bad advertising revenue tracking both Universal Analytics and Google Analytics.

上个月,我们使用angularJs从多页应用切换到单页应用,并立即开始获得跟踪Universal Analytics和Google Analytics的不良广告收入。

We are also using Google Tag Manager to fire off our events.

我们还使用Google跟踪代码管理器来启动我们的活动。

Our current lead is a tidbit from https://developers.google.com/analytics/devguides/collection/analyticsjs/single-page-applications

我们目前的领先优势来自https://developers.google.com/analytics/devguides/collection/analyticsjs/single-page-applications

Which states:

Do not update the document location

不要更新文档位置

In the same way that the tracker uses document.referrer for the referrer field, it uses document.location for the location field, which will often contain campaign data or other meta data in the form of query parameters appended to the end of the URL.

与跟踪器使用document.referrer作为referrer字段的方式相同,它使用document.location作为location字段,该字段通常包含附加到URL末尾的查询参数形式的广告系列数据或其他元数据。

Updating any of the campaign fields or other meta data that Google Analytics is checking for may cause the current session to end and a new session to begin. To avoid this problem, do not update the location field when tracking virtual pageviews in a single page application. Use the page field instead.

更新Google Analytics正在检查的任何广告系列字段或其他元数据可能会导致当前会话结束并开始新会话。要避免此问题,请勿在单个页面应用程序中跟踪虚拟综合浏览量时更新位置字段。请改用页面字段。

It also includes this note

它还包括此注释

Note: if you send a hit that includes both the location and page fields and the path values are different, Google Analytics will use the value specified for the page field.

注意:如果您发送包含位置和页面字段且路径值不同的匹配,Google Analytics将使用为页面字段指定的值。

To us, this says that if you include the 'page' field it will trump a 'location' field value and that if you include a 'location' field without a 'page' field after the initial page load you run the risk of starting a new session possibly with the campaign tracking stripped.

对我们来说,如果您包含“页面”字段,它将胜过“位置”字段值,如果您在初始页面加载后包含没有“页面”字段的“位置”字段,则存在启动风险可能会删除广告系列跟踪的新会话。

Using the google analytics debugger chrome extension we were able to identify events that were indeed firing a location parameter and without a page parameter.

使用谷歌分析调试器chrome扩展,我们能够识别确实触发位置参数而没有页面参数的事件。

A user hits our page, GTM fires a page view with the 'location' parameter. Subsequent virtual page views were including both 'location' and 'page' parameters. However we were also firing an event when a user opens their shopping cart that and that includes a 'location' parameter and not a 'page' parameter.

用户点击我们的页面,GTM使用'location'参数触发页面视图。后续虚拟页面视图包括“位置”和“页面”参数。但是,当用户打开购物车并且包含“位置”参数而不是“页面”参数时,我们也会触发一个事件。

We just updated our GTM configuration to try to remedy this and have our fingers crossed that it will work. I'll update my post if we find a solution.

我们刚刚更新了我们的GTM配置,试图解决这个问题,并指出它会起作用。如果我们找到解决方案,我会更新我的帖子。

We've been wrestling with this for WAY too long now.

我们一直在为这个问题挣扎太久了。

#2


I'm facing the same problem (currently implementing the solution.. only did some research) and it might have something to do what Google only is mentioning in their docs briefly, namely: Do not create new trackers. GTM does create a new tracker each time..

我面临着同样的问题(目前正在实施解决方案......只进行了一些研究)并且它可能有一些事情要做,谷歌只是简单地在他们的文档中提到,即:不要创建新的跟踪器。 GTM每次都会创建一个新的跟踪器..

Possible solution

Do not let GTM initiate a new tracker each time but set trackerName in GTM like 'spaTracker' for your Single Page App.

不要让GTM每次都启动一个新的跟踪器,而是在GTM中设置跟踪器名称,​​例如单个应用程序的“spaTracker”。

Google分析(通过代码管理器)在第一次网页加载后会丢失对访问者的跟踪

All credits go to Thyngster.

所有学分都归Thyngster所有。

#1


We at betabrand.com are having very similar troubles.

我们betabrand.com遇到了非常类似的麻烦。

Last month we switched from a multipage to a single page app using angularJs and immediately starting getting bad advertising revenue tracking both Universal Analytics and Google Analytics.

上个月,我们使用angularJs从多页应用切换到单页应用,并立即开始获得跟踪Universal Analytics和Google Analytics的不良广告收入。

We are also using Google Tag Manager to fire off our events.

我们还使用Google跟踪代码管理器来启动我们的活动。

Our current lead is a tidbit from https://developers.google.com/analytics/devguides/collection/analyticsjs/single-page-applications

我们目前的领先优势来自https://developers.google.com/analytics/devguides/collection/analyticsjs/single-page-applications

Which states:

Do not update the document location

不要更新文档位置

In the same way that the tracker uses document.referrer for the referrer field, it uses document.location for the location field, which will often contain campaign data or other meta data in the form of query parameters appended to the end of the URL.

与跟踪器使用document.referrer作为referrer字段的方式相同,它使用document.location作为location字段,该字段通常包含附加到URL末尾的查询参数形式的广告系列数据或其他元数据。

Updating any of the campaign fields or other meta data that Google Analytics is checking for may cause the current session to end and a new session to begin. To avoid this problem, do not update the location field when tracking virtual pageviews in a single page application. Use the page field instead.

更新Google Analytics正在检查的任何广告系列字段或其他元数据可能会导致当前会话结束并开始新会话。要避免此问题,请勿在单个页面应用程序中跟踪虚拟综合浏览量时更新位置字段。请改用页面字段。

It also includes this note

它还包括此注释

Note: if you send a hit that includes both the location and page fields and the path values are different, Google Analytics will use the value specified for the page field.

注意:如果您发送包含位置和页面字段且路径值不同的匹配,Google Analytics将使用为页面字段指定的值。

To us, this says that if you include the 'page' field it will trump a 'location' field value and that if you include a 'location' field without a 'page' field after the initial page load you run the risk of starting a new session possibly with the campaign tracking stripped.

对我们来说,如果您包含“页面”字段,它将胜过“位置”字段值,如果您在初始页面加载后包含没有“页面”字段的“位置”字段,则存在启动风险可能会删除广告系列跟踪的新会话。

Using the google analytics debugger chrome extension we were able to identify events that were indeed firing a location parameter and without a page parameter.

使用谷歌分析调试器chrome扩展,我们能够识别确实触发位置参数而没有页面参数的事件。

A user hits our page, GTM fires a page view with the 'location' parameter. Subsequent virtual page views were including both 'location' and 'page' parameters. However we were also firing an event when a user opens their shopping cart that and that includes a 'location' parameter and not a 'page' parameter.

用户点击我们的页面,GTM使用'location'参数触发页面视图。后续虚拟页面视图包括“位置”和“页面”参数。但是,当用户打开购物车并且包含“位置”参数而不是“页面”参数时,我们也会触发一个事件。

We just updated our GTM configuration to try to remedy this and have our fingers crossed that it will work. I'll update my post if we find a solution.

我们刚刚更新了我们的GTM配置,试图解决这个问题,并指出它会起作用。如果我们找到解决方案,我会更新我的帖子。

We've been wrestling with this for WAY too long now.

我们一直在为这个问题挣扎太久了。

#2


I'm facing the same problem (currently implementing the solution.. only did some research) and it might have something to do what Google only is mentioning in their docs briefly, namely: Do not create new trackers. GTM does create a new tracker each time..

我面临着同样的问题(目前正在实施解决方案......只进行了一些研究)并且它可能有一些事情要做,谷歌只是简单地在他们的文档中提到,即:不要创建新的跟踪器。 GTM每次都会创建一个新的跟踪器..

Possible solution

Do not let GTM initiate a new tracker each time but set trackerName in GTM like 'spaTracker' for your Single Page App.

不要让GTM每次都启动一个新的跟踪器,而是在GTM中设置跟踪器名称,​​例如单个应用程序的“spaTracker”。

Google分析(通过代码管理器)在第一次网页加载后会丢失对访问者的跟踪

All credits go to Thyngster.

所有学分都归Thyngster所有。