我如何在Google点击转换上存储美元和美分的转换价值?
我正在使用REST API将点击转换发布到Google广告。 我需要知道如何指定conversionValue
的数值,并且需要知道,如果我将其作为“ 0.01”作为JSON中的双引用字符串,如果它可以工作或者如果它将其计算为零,因为它不是数值的值?
还要注意 so so atrate 并没有真正回答,因为它作为 tracking的值谈论的值Pixel 将转换转换为Google的版本,而不是用于发布离线转换的JSON API值。有趣的是,这是如此的海报似乎有某种证明Google将此价值存储为双倍,尽管我看不到任何文件。我也不知道API在传递到此值时如何处理“ 0.01”的字符串,以及它是否以双重格式将其转换为0.01,以使其不会在该数据上失去精确度。
In Google's Click Conversion object documentation, they do not describe the conversionValue
parameter very well. They say it must be a numerical value. However, often times with numerical values in programming, there are some issues with numbers being passed that become floats and the precision can sometimes be lost, giving you an unexpected output compared to your input. For instance, in some eCommerce APIs, they want you to overcome this float problem by passing monetary values by multiplying the value by 100. So, let's say I want to pass '0.01' in this field. Is the API flexible enough if I pass it as 0.01 and not in a string? Or if I wrap it as a string like '0.01', will it automatically compute its numerical value with no float precision issue? Or, do I need to treat it like many eCommerce APIs and multiply it by 100 and pass it as (0.01*100) or 1?
I'm using the REST API for posting click conversions to Google Ads. I need to know how to specify the numerical value for conversionValue
, and need to know that if I pass it as "0.01" as a double-quoted string in the JSON, if it will work or if it will compute it as zero because it wasn't a numerical value?
Note also that this SO article doesn't really answer because it's talking about the value as a tracking pixel version of posting the conversion to Google, and not a JSON API value used for posting offline conversions. It was interesting to note that this SO poster seemed to have some kind of proof that Google stores this value as a Double, although I don't see any documentation for this. I also don't know how the API treats a string of "0.01" when being passed to this value, and whether it converts it to 0.01 in a Double format in such a way that it won't lose precision on that data.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Google ADS API团队的Peter Laurence通过电子邮件于7/6/2022与我联系,并指出数值是双重的。一个人可以将值作为字符串或json传递给REST API的数字传递,它将以双重而不是float存储。
唯一的缺点是,当将10.20之类的东西作为双重存储时可能会成为10.2,但您至少不会损失美分,也不会发生舍入。
Peter Laurence from the Google Ads API Team got back to me via email on 7/6/2022 and indicated that the numerical value is a double. One can pass the value as a string or a number with the JSON passed to the REST API and it will store as a double, not a float.
The only drawback is that something like 10.20 might end up as a 10.2 when stored as a double, but you won't lose at least the cents and no rounding occurs.