如何通过 GA 的新 analytics.js 设置自定义变量 [英] How to set custom variables through the new analytics.js of GA

查看:22
本文介绍了如何通过 GA 的新 analytics.js 设置自定义变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请参阅指南 https://developers.google.com/analytics/devguides/collection/analyticsjs/custom-dims-mets

我找不到任何方法来跟踪自定义变量,例如旧的跟踪 jsga.js":https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingCustomVariables

I cant find any way to track Custom Variables like the old tracking js "ga.js": https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingCustomVariables

_setCustomVar(index, name, value, opt_scope)

有人可以帮忙吗?

谢谢!

推荐答案

analytics.js(又名 Universal Analytics)中不再存在自定义变量.它已被更灵活、更强大的自定义维度和指标所取代.

Custom Variables don't exist any more in analytics.js (aka Universal Analytics). It has been replace with Custom Dimensions and Metrics that are more flexible and powerful.

自定义指标和维度的优势:

Advantages of Custom Metrics and dimensions:

  • 它们可用于过滤器
  • 他们是界面中的一等公民,因此您将在界面中看到自定义变量名称(而不是通用的自定义变量 5")
  • 在界面中配置
  • 聚合的指标(无法使用自定义变量)
  • 20 个自定义维度 + 20 个自定义指标可用,而不仅仅是 5 个自定义变量

为了使用自定义维度/指标,您需要在界面上配置它们.进入管理员,深入查看您的网络资产,然后有一个自定义定义"选项卡.

In order to use Custom Dimensions/Metrics, you need to configure them on the interface. Go into admin, drill down into your web property and then there is a tab for "custom definitions".

那么当你跟踪它的时候,你只需要跟踪自定义属性的值和id就可以了,例如:

Then when you track it, you just need to track the value and the id of the custom property eg:

ga('send', 'pageview', {
  'dimension15':  'My Custom Dimension'
});

这将发送附加了自定义维度的综合浏览量.

This will send a pageview with the custom dimension attached to it.

您还可以在页面上设置一个将应用于页面上发生的任何浏览量或事件.

You can also set one on the page that will be applied to any pageviews or events that happened on the page.

ga('set', 'dimension5', 'custom data');

请注意,仅设置它不会发送到 GA,因此如果您决定使用 set,请确保之后至少在页面上调用一次 send实际上将该数据发送给 GA.

Note that only setting it won't send to GA, so if you decide to use set make sure you call a send afterwards at least once on the page to actually send that data to GA.

更多信息:开发者文档

这篇关于如何通过 GA 的新 analytics.js 设置自定义变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆