跨域的 gtag 链接器

问题描述

我正在尝试使用新的 gtag 在网址中设置链接,但在网址中看不到链接代码

我这样设置谷歌分析:

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 定义网址吗? 提前致谢

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)