英文:
Why does gtag.js specify the same ID twice in the installation code?
问题
为什么 G-ZQA9CN2Q3Z
被提及两次?
如果我想同时安装两个 GA4,是否需要加载两次 <script />
标签?
英文:
The GA4 gtag.js installation code is as follows:
<!-- Google tag (gtag.js) -->
<script
async
src="https://www.googletagmanager.com/gtag/js?id=G-ZQA9CN2Q3Z"
></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag('js', new Date());
gtag('config', 'G-ZQA9CN2Q3Z');
</script>
Why was G-ZQA9CN2Q3Z
mentioned twice?
Is it necessary to load the <script />
tag twice if I want to install two ga4 at the same time?
答案1
得分: 1
我相信URL中的那个部分通过最初加载指定的ID代码来加快速度。因此,请在URL中指定您最重要的ID,然后配置所有的ID。
如果您检查网络,您会看到每个ID都有一个请求。
英文:
I believe the one in the URL helps speed things up a bit by loading the specified IDs code initially. So specify your most important ID in the URL and then config all your IDs.
If you check the network, you will see there is a request per ID.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论