gpt4 book ai didi

angular - 谷歌分析 : add custom interaction field to social interaction

转载 作者:行者123 更新时间:2023-12-03 16:07:52 27 4
gpt4 key购买 nike

有时我的应用程序 UI 中有两个共享按钮(取决于状态)。它们可以共享相同的数据,但位于 UI 的不同部分。我们想要分析从哪个按钮(UI 的一部分)执行了共享。我希望使用 fieldsObject这部分的字段,如 documentation: 中所示
ga('send', 'social', [socialNetwork], [socialAction], [socialTarget], [fieldsObject]);
然而,我能找到的所有例子都只使用了前三个字段,通常是这样的:
ga('send', {
hitType: 'social',
socialNetwork: 'Twitter',
socialAction: 'share',
socialTarget: 'http://www.example.com/article-01'
});

另外,我不明白文档的含义:

"Note that as with all send commands, the fields passed in the convenience parameters may also be specified in the fieldsObject."



我想也许我正在利用“便利参数”。
我的共享代码(来自 Angular 服务):
reportShare(media:string, context: string) {
let pageUrl: string = this.sanitizeURL();
ga('send', {
hitType: 'social',
socialNetwork: media,
socialAction: 'share',
socialTarget: pageUrl,
fieldsObject: context
});
}

我的谷歌分析调试器说:
VM5405 analytics_debug.js:16 Running command: ga("send", {hitType: "social", socialNetwork: "Twitter", socialAction: "share", socialTarget: "/find/1160", fieldsObject: "machine"})
但是之后: Set called on unknown field: "fieldsObject".
从其余部分我们可以看出,“fieldsObject”没有被传递:
adSenseId (&a) 1505578412
anonymizeIp (&aip) 1
apiVersion (&v) 1
clientId (&cid) 1703756191.1573561297
encoding (&de) UTF-8
hitType (&t) social
javaEnabled (&je) 0
language (&ul) en-us
location (&dl) http://localhost/find/1160
screenColors (&sd) 24-bit
screenResolution (&sr) 1680x1050
socialAction (&sa) share
socialNetwork (&sn) Twitter
socialTarget (&st) /find/1160
title (&dt) This pagetitle
trackingId (&tid) UA-*********-1
viewportSize (&vp) 1680x916

有没有办法使用社交互动将 fieldsObject 与我的上下文字符串一起传递?

最佳答案

您不应该命名该 fieldObjects。
文档指出 fieldObjects 是未在字段签名中传递的对象,这意味着您要发送的任何其他字段。文档说明了 fieldObjects:

An object for specifying any remaining values not specified in any of the fields parameters.

If a field is set in both a fields parameter and fieldsObject, the value in fieldsObject will be used.



所以我认为应该是:
ga('send', {
hitType: 'social',
socialNetwork: media,
socialAction: 'share',
socialTarget: pageUrl
},
{
anyOtherLabel: value
}
);

ga 命令的文档引用和更多示例可以在这里查看: https://developers.google.com/analytics/devguides/collection/analyticsjs/command-queue-reference#method-details

关于angular - 谷歌分析 : add custom interaction field to social interaction,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58991163/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com