google-people-api - 跨域的 gtag 链接器
问题描述
我正在尝试使用新 gtag 在 URL 中设置链接,但在 URL 中看不到链接的代码。
我这样设置谷歌分析:
gaScript.setAttribute('async', 'true');
gaScript.setAttribute('src', `https://www.googletagmanager.com/gtag/js?id=${ trackingID }`);
and
gaScript2.innerText = `window.dataLayer = window.dataLayer || [];function gtag(){dataLayer.push(arguments);}gtag(\'js\', new Date());gtag(\'config\', \'${ trackingID }\', {\'linker\': {'domains': [\'${crossDomain}\']}});`;
嗨有这个:
const decorateURL = (url: string) => {
let destinationLink = false;
if (ga) {
let tracker = ga.getAll()[0];
let linker = new window.gaplugins.Linker(tracker);
destinationLink = linker.decorate(url);
}
return (destinationLink ? url + '?' + destinationLink : url);
}
和电话:
window.location.assign(decorateURL(data.redirectUrl));
目前, o 收到一条错误消息:
Uncaught ReferenceError: ga is not defined
有人可以帮忙用 gtag 定义网址吗?提前致谢
解决方案
推荐阅读
- php - HTTP ERROR 500:脚本“index.php”的标头格式错误
- sql - 触发器中的调用函数
- javascript - 使用 mongoose 管理 mongoDB 中的重复子文档
- google-apps-script - 我希望我在列的单元格内输入的值自动转换为负谷歌应用脚本
- java - jps、jstat、jstack 等命令显示“
未找到” - snowflake-cloud-data-platform - 在雪花中处理半结构化数据
- android - 项目名称和 ApplicationID 匹配,但我仍然收到此错误:找不到包名称“capacitor.android.plugins”的匹配客户端
- java - Apache POI 和 CellType
- javascript - Onclick复选框不会改变
- c++ - 我在多项式中添加重复项的代码不起作用(程序是使用链表将两个多项式相乘)