简体   繁体   English

在 Google Analytics 中转换数据类型电子商务变量?

[英]Convert Data Type Ecommerce Variables in Google Analytics?

The Google documentation for e-commerce has data types https://support.google.com/tagmanager/answer/6107169?hl=en ,电子商务的 Google 文档具有数据类型https://support.google.com/tagmanager/answer/6107169?hl=en

For example, transactionTotal type = numeric .例如, transactionTotal type = numeric If my developer passed it as a string, will the automatic data type conversion be applied to Google Analytics.如果我的开发人员将其作为字符串传递,自动数据类型转换是否会应用于 Google Analytics。 In other words, does the service automatically convert types if they are set differently than in the documentation?换句话说,如果它们的设置与文档中的不同,服务会自动转换类型吗?

In https://ga-dev-tools.appspot.com/dimensions-metrics-explorer/ Revenue (TransactionTotal) have type Currency...https://ga-dev-tools.appspot.com/dimensions-metrics-explorer/Revenue (TransactionTotal) 的类型为 Currency... 在此处输入图像描述

Thanks谢谢

Traditionally, the data is passed to the Google Server by requesting a transparent pixel from the Google Analytics server with the payload attached as query string.传统上,数据通过从谷歌分析服务器请求一个透明像素并将有效负载作为查询字符串附加到谷歌服务器。

"String" is a giveaway here, the query string would not preserve any data types. “字符串”在这里是一个赠品,查询字符串不会保留任何数据类型。

Also, Javascript does not strongly enforce data types (and indeed does not have a currency type), and even if it did, the measurement protocol (on which current iterations of GA are built) is supposed to language agnostic and cannot make assumptions on what data types are supported by the client that makes the call.此外,Javascript 并没有强制执行数据类型(并且确实没有货币类型),即使这样做了,测量协议(构建 GA 的当前迭代)也应该与语言无关,并且不能对什么做出假设进行调用的客户端支持数据类型。

So no matter from which perspective you look at it, what Google receives are strings.所以无论从哪个角度看,谷歌收到的都是字符串。 They need to be properly formed (eg numeric for metrics) and formatted strings, but they are strings nonetheless.它们需要正确地形成(例如用于度量的数字)和格式化的字符串,但它们仍然是字符串。

"Data type currency" might refer to the fact that GA is able to do currency conversions on this field (if the currency in your transaction and the currency set for the view are different), but from a code perspective this is just a float (or a numeric string with a point as decimal separator - in my experience passing floats and ints as quoted string will work, but might show up as wrong type in some debuggers). “数据类型货币”可能是指 GA 能够在此字段上进行货币转换(如果您的交易中的货币和为视图设置的货币不同),但从代码的角度来看,这只是一个浮点数(或带有点作为小数分隔符的数字字符串 - 根据我的经验,将浮点数和整数作为带引号的字符串传递会起作用,但在某些调试器中可能会显示为错误的类型)。 So this would refer to something internal to GA, not to your tracking code.所以这指的是 GA 内部的东西,而不是你的跟踪代码。

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

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