如何通过 Google 标签管理器在 AMP 容器中添加自定义 HTML & Javascript 标签?

How can I add custom HTML & Javascript tags in AMP Container through Google Tag Manager?

我正在我的网站中实施 AMP。我想通过 Google 标签管理器自定义 HTML 标签调用所有外部脚本。遗憾的是,它仅适用于 Web 版本的容器,不适用于 AMP 版本的容器。如何通过 Google 标签管理器在 AMP 容器中添加自定义 HTML & Javascript 标签?

自定义 HTML 标记在 GTM AMP 容器中按设计不可用。来自 AMPs documentation

script tags are prohibited except the mandatory script tag to load the AMP runtime and the script tags to load extended components. Non executable script tags such as ld+json tags are allowed.

如果没有可用的模板,则无法在 atm 上实施。 AMP 的本质是 google 禁止您使用自定义 javascript,这可能会减慢页面速度。

只能使用在 GTM 中具有模板的第 3 方代码。 请注意,有几个第 3 方标签允许在您的 amp 页面中进行硬编码,但没有 GTM 模板,示例 = Gemius 标签。

您在 AMP 页面上使用 GA/GTM 的 atm 非常有限。