From 3915c065feda0eaa979e055ad8d347db0a58212a Mon Sep 17 00:00:00 2001 From: spylecym <1262965753@qq.com> Date: Mon, 12 Aug 2024 09:12:30 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=98=E7=BD=91=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E8=B0=B7=E6=AD=8C=E5=88=86=E6=9E=90=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/site/js/common.js | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/public/site/js/common.js b/public/site/js/common.js index 5ee455694..19726624b 100644 --- a/public/site/js/common.js +++ b/public/site/js/common.js @@ -203,19 +203,32 @@ const openInNewTab = (url)=> { // 引入谷歌分析代码 let scriptElement = document.createElement('script'); scriptElement.async = true; -scriptElement.src = 'https://www.googletagmanager.com/gtag/js?id=AW-16660800396"'; +scriptElement.src = 'https://www.googletagmanager.com/gtag/js?id=AW-16660800396'; +let scriptElement1 = document.createElement('script'); +scriptElement1.async = true; +scriptElement1.src = 'https://www.googletagmanager.com/gtag/js?id=G-PE77P6491J'; // 在 script 元素加载完成后执行的回调函数 scriptElement.onload = function() { - 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); + 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); +}; +scriptElement1.onload = function() { + let customScript = document.createElement('script'); + customScript.textContent = ` + window.dataLayer = window.dataLayer || []; + function gtag(){dataLayer.push(arguments);} + gtag('js', new Date()); + gtag('config', 'G-PE77P6491J'); ` + document.head.appendChild(customScript); }; // 将 script 元素插入到文档的 head 元素中 document.head.appendChild(scriptElement); +document.head.appendChild(scriptElement1);