...将 Google Analytics 代码 sn-p 移动到外部代码文件,
托管在已被您的脚本源列入许可名单的域上
定向的,例如您网站的主域。
最初由谷歌提供的脚本是:
<!-- Google tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-##########">
</script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-##########');
</script>
我去了https://www.googletagmanager.com/gtag/js?id=UA-##########,下载了脚本,并将其添加到它的底部:
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-##########');
我把它保存到我的网站上。我添加了这个:
<script async src="/script-saved-to-my-website.js"></script>
...里面头部部分。 (出于某种原因,谷歌广告似乎希望它位于头部部分)。
我按照上面文章中的描述添加了 csp 策略。
我使用在 Google Analytics 中找到的“连接到 Google 广告”功能将 Google Analytics 4 连接到 Google Ads。注意:您必须让 Google Ads 处于专家模式,而不是智能模式,此功能才能发挥作用。
我在 Google Ads 上设置了转化目标。
而且...它正在工作。 :) 我可以在 Google Analytics 上看到我的统计数据,在 Google Ads 上看到我的转化。