【发布时间】:2021-09-14 23:34:05
【问题描述】:
由于某种原因,Google 标签管理器在动态添加时不会加载任何 cookie
当用户点击某个接受按钮时,我将 script 标记添加到 body 与 src 的 https://www.googletagmanager.com/gtag/js?id=${GOOGLE_TAGS_ID} 并在加载后运行:
function gtag(...args: any[]) {
window.dataLayer.push(args);
}
// After the script has finish loading I called this function
function load() {
gtag('js', new Date());
gtag('config', GOOGLE_TAGS_ID);
}
【问题讨论】:
标签: javascript typescript google-analytics google-tag-manager