Google 跟踪代码管理器容器 - 开发人员。网站到已发布网站的建议

发布于 2025-01-10 05:04:59 字数 429 浏览 0 评论 0原文

我只是想确保在下周发布我们的网站时能够正确地解决这个问题,该网站已经添加了一些页面。非常感谢任何建议。

因此,截至目前,我们在 Google 跟踪代码管理器中拥有一个原始容器(容器 1),它已经设置了一些标签并正在运行,非常棒。 上周,我在 GTM 中创建了一个新容器(容器 2),并一直使用它来测试我们的开发。网站。在我们网站的新页面中添加一些标签,以便我准备在网站上线后将它们添加到我们实际发布的网站中。

当我创建容器 2 时,我将 GTM 代码发送给开发人员,他将其放入开发人员的标头中。网站 我的问题是......当我们发布开发时。我们是否需要从标头中删除该代码并将其替换为容器 1 的代码,这样我们就可以对现有标签进行操作,而我只需复制我在容器 2 中创建的几个标签?

澄清:我想保留容器 1 中的标签并使用此容器,因为网站仍然需要所有这些标签,我只是为网站的其他页面创建标签,否则保持不变。

I just wanted to make sure I would be approaching this problem correctly when it comes time to publish our website next week that has had a few pages added onto it. Any advice is greatly appreciated.

So, as of right now we have an original container (Container 1) in Google Tag Manager, it has a few tags set up and working, great.
Last week, I created a new container in GTM (Container 2) and have been using that to test our dev. website. Adding a few tags to the new pages of our website so I am ready to add them to our actual published website once it goes live.

When I created Container 2 I sent the GTM code to the developer and he put it into the header of the dev. website
My question is.. when we publish the dev. website are we going to need to remove that code from the header and replace it with Container 1's code that way we are operating on the existing tags and I only have to replicate the few tags I made in Container 2?

Clarification: I want to keep my tags from Container 1 and use this container as the website still needs all these tags, I was just creating tags for additional pages to the website, it has otherwise remained the same.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

以为你会在 2025-01-17 05:05:00
  1. 一般来说,您不应该使用单独的 GTM 容器来存放下缸体。 GTM 有专门针对这种情况制作的自己的环境。您可以在 GTM 中创建一个较低的环境,获取它的代码并将其安装在您网站的较低环境中。有关详细信息,请参见:https://support.google.com/tagmanager/answer /6311518?hl=en
  2. 大多数使用 GTM 的网站都会在 prod 和 lowers 上使用相同的容器和相同的 GTM env。他们只需使用 GTM 中的预览功能来确保一切都符合预期并发布到他们拥有的唯一环境。而且在绝大多数情况下它都工作得很好。
  3. 在极少数情况下,开发和生产使用不同的 GTM 容器是合理的。但是,当您这样做时,您必须保持两个容器等效,并且现在发布到产品必须涉及将更改从一个容器移动到另一个容器,这不是使用 GTM 的典型方式,因此 GTM 本身不具备功能优雅地做到这一点。您必须导出和导入整个工作区并对产品容器进行更改,或者使用这个方便的扩展:https://chrome.google.com/webstore/detail/gtm-copy-paste/mhhidgiahbopjapanmbflpkcecpciffa?hl=en

现在我们已经概述了应该如何完成事情,让我们来回答您的问题:手。

基本上,您的问题是询问您的开发人员在将下层推送到产品时是否会用容器 2 替换容器 1。问问他们。但一般来说,最好做好三件事:

  1. 让开发人员永远不要将 GTM 代码从开发版本推送到产品版本,并在开发版本和产品版本上维护不同的 GTM 代码段。

  2. 在您的容器中拥有通用的与容器无关的跟踪逻辑,这样即使开发人员将开发容器推送到生产环境,您的跟踪仍然是完美的,并且所有事件都将发送到生产 GA 而不是开发 GA。

  3. 具有通用的、与容器无关的逻辑,如果 console. 检测到在产品上使用开发容器,则会发出 GTM 消息警告。

那里。

简而言之,对您来说最简单的事情就是始终将容器 1 保留在生产环境中,将容器 2 保留在开发环境中,但保持它们之间的对等性,并在每次完成工作时将更改从 2 移至 1。这是权宜之计。

正确的做法是完全删除容器 2,在容器 1 中创建一个环境,将较低环境容器 1 的代码部署到开发人员,通知开发人员该容器仅用于开发人员,并确保您的代码是通用的。

  1. Generally, you're not supposed to use a separate GTM container for lowers. GTM has its own environments made exactly for this case. You can just make a lower environment in GTM, get code for it and install it on your site's lower env. Here's more on it: https://support.google.com/tagmanager/answer/6311518?hl=en
  2. Most of sites that use GTM, would use the same container and the same GTM env on prod and on lowers. They would just use the preview function in GTM to make sure everything's as expected and publish to the only env they have. And it works pretty fine in vast majority of cases.
  3. In rare cases, it can be justified to have different GTM containers for dev and prod. But when you do this, you will have to keep both containers equivalent and your publishing to prod now would have to involve moving changes from one container to another, which is not a typical way of using GTM, so GTM itself doesn't have capabilities to do that elegantly. You would have to either export and import the whole workspace with changes to the prod container, or use this handy extension: https://chrome.google.com/webstore/detail/gtm-copy-paste/mhhidgiahbopjapanmbflpkcecpciffa?hl=en

Now that we've overviewed how things should be done, let's get to your question at hand.

Your questions is, basically, asking whether your developers are going to replace container 1 with container 2 when pushing the lowers to prod. Ask them. But generally, it's better to have three things in place:

  1. Have developers never push the GTM code from dev to prod, maintaining different GTM snippets on dev and prod.

  2. Have a universal container-agnostic tracking logic in your containers, so that even if the developers push the dev container to prod, your tracking is still perfect and all the events are going to the production GA rather than dev GA.

  3. Have a universal, container-agnostic logic that console.warns a GTM message if it detects that the dev container is being used on prod.

There.

In short, the easiest thing for you is to keep container 1 on prod and 2 on dev always, but maintain parity between them and move changes from 2 to 1 every time you're done with your work. That's the expedient option.

The proper thing to do is to remove container 2 completely, create an environment in container 1, have your lower env container 1 code deployed to dev, notify the devs that that container is for dev only and make sure your code there is universal.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文