mirror of
https://github.com/kuaifan/dootask.git
synced 2025-12-12 11:19:56 +00:00
feat: 页面新增谷歌分析
This commit is contained in:
parent
2926472f7d
commit
b56ba93634
18
public/site/js/common.js
vendored
18
public/site/js/common.js
vendored
@ -200,5 +200,23 @@ const openInNewTab = (url)=> {
|
||||
const win = window.open(url, '_blank');
|
||||
win.focus();
|
||||
}
|
||||
// 引入谷歌分析代码
|
||||
let scriptElement = document.createElement('script');
|
||||
scriptElement.async = true;
|
||||
scriptElement.src = 'https://www.googletagmanager.com/gtag/js?id=AW-16660800396"';
|
||||
|
||||
// 在 script 元素加载完成后执行的回调函数
|
||||
scriptElement.onload = function() {
|
||||
console.log('The gtag.js script has been loaded successfully.');
|
||||
let customScript = document.createElement('script');
|
||||
customScript.textContent = `
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(){dataLayer.push(arguments);}
|
||||
gtag('js', new Date());
|
||||
gtag('config', 'AW-16660800396');`
|
||||
document.head.appendChild(customScript);
|
||||
};
|
||||
// 将 script 元素插入到文档的 head 元素中
|
||||
document.head.appendChild(scriptElement);
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user