Sponsored Content
The Wayback Machine - https://web.archive.org/web/20210817024815/https://github.com/google/site-kit-wp/issues/413
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow having secondary Tag Manager container if site uses paired AMP #413

Closed
kmwilkerson opened this issue Aug 16, 2019 · 3 comments
Closed

Allow having secondary Tag Manager container if site uses paired AMP #413

kmwilkerson opened this issue Aug 16, 2019 · 3 comments

Comments

@kmwilkerson
Copy link

@kmwilkerson kmwilkerson commented Aug 16, 2019 •

Note: The original report below includes multiple issues, but let's use this issue only to track "Issue 1" below.

Related resources:

Here's a screenshot (sorry, German) showing that there is a specific container type for AMP:
Screenshot 2019-08-22 at 15 56 19

Bug Description

Issue 1: When the connection to GTM is made, it automatically inserts the GTM script across standard pages and AMP pages. However, the same GTM container is not meant to be used in both places, as GTM requires a unique container for AMP pages. When the Site Kit GTM connection is made, there needs to be a container selection for standard pages, and a second for AMP pages. Or an option to not insert on AMP.

Issue 1a: The Site Kit GTM script is missing the second half of the required snippet on AMP pages (that goes in the < body >).

Issue 1b: Additionally, there should probably be a note to let the user know to remove the analytics settings they may have input within the AMP plugin settings. As having AMP plugin analytics enabled + Site Kit GTM OR GA auto insert enabled will result in inflated data. This same risk applies to enabling the auto-insert of Site Kit GA snippet with GTM. GA snippet + GTM snippet should not coexist on a page together (when GA is an active variable in GTM), as that too could result in doubled data.

Steps to reproduce

Info for issue 1:
https://support.google.com/tagmanager/answer/9205783
The reason the same container shouldn't be used on both standard pages and AMP pages is due to AMP limitations when it comes to variables, tag types, and how those tags are fired. If the standard GTM container is used on AMP, there could be errors that prevent any data collection at all.

Steps to reproduce issue 1b:

  1. Enable AMP plugin.
  2. Input GA information within AMP plugin analytics settings.
  3. Connect GA (allow snippet placement) and GTM in Site Kit.
  4. View the source on AMP pages -- see all 3 being called -- GA, GTM, + GA a second time from the AMP settings.
  5. In real-time in GA, see 2 pageviews counted for this single "real" pageview. (You won't see 3 due to the Site Kit GTM script missing its corresponding body tag.)

Screenshots

1a Two parts are required for GTM on AMP pages. Site Kit is currently only inserting the < head > snippet.

Screen Shot 2019-08-16 at 4 00 03 PM

1b Source code of AMP page with Site Kit GA + Site Kit GTM + AMP plugin analytics

Site Kit bug

Additional Context

  • AMP Plugin Version 1.2

This issue is blocked by #432 and #433.


Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance criteria

During GTM setup, check if the site is using paired AMP. If yes:

  • display text: "Looks like your site is using paired AMP. Please select your Tag Manager account and relevant containers below, the snippets will be inserted automatically to your site."
  • add a third drop down for the AMP container.

Screenshot 2020-01-27 at 23 45 15

* all drop-downs should have an option either to set up a new account or set up a new container. * in the GTM section of Settings, add information about the AMP container ID as well.

Implementation Brief

In Tag Manager setup, if ampMode is secondary:

  • Render an additional drop down for AMP Container which only lists containers where usageContext is amp
    • The added dropdown should also have a "Setup a new container" option
  • Internally, the component will need to store ampContainers which it can query from the containers datapoint with usageContext of amp
    • Ideally a single datapoint could return containers for both usage contexts (consistent with Google API)
    • Let's update the containers datapoint to support multiple usageContexts
  • Update the settings view for Tag Manager to show the AMP container ID

Changelog entry

  • Properly support paired AMP in Tag Manager module by allowing to select two different containers, one for web context and the other for amp context.
@felixarntz felixarntz changed the title GTM and GA conflict with AMP plugin Create Tag Manager container specific for AMP if site uses AMP Aug 22, 2019
@felixarntz
Copy link
Member

@felixarntz felixarntz commented Aug 22, 2019

Thanks for the detailed report @kmwilkerson!

Since you reported multiple issues, we split these into a few:

  1. We will use this issue to track implementation of dealing with Tag Manager for AMP differently than for non-AMP. In other words, Site Kit should ensure that, for AMP content, the Tag Manager container is an "AMP" container, and for non-AMP, the container is a "Web" container.
    1a. As far as I can see, that is not an actual issue. We do insert the second part too, just not at the beginning of the body tag, which however is not an actual problem. You can actually see this piece inserted in your screenshot in 1b - can you confirm?
    1b. It is indeed a problem, we do not currently detect existing Tag Manager snippets in the page. I opened #433 to track that. Also related, our snippet detection does not work for sites that use AMP as a secondary version (like in your case), so for fixing that I opened #432.

I hope that addresses the problems!

@felixarntz felixarntz added the P0 label Aug 22, 2019
@felixarntz felixarntz changed the title Create Tag Manager container specific for AMP if site uses AMP Allow having secondary Tag Manager container if site uses paired AMP Aug 28, 2019
@felixarntz felixarntz added P1 and removed P0 labels Jan 28, 2020
@aaemnnosttv aaemnnosttv self-assigned this Jan 29, 2020
@felixarntz
Copy link
Member

@felixarntz felixarntz commented Jan 31, 2020

IB ✅

@aaemnnosttv Just to clarify, in settings the containers that are displayed should also depend on the AMP mode. E.g. an AMP container should only be shown if primary or secondary AMP, a non-AMP container should only be shown if secondary AMP or no AMP.

@felixarntz felixarntz removed their assignment Jan 31, 2020
@ThierryA ThierryA removed the Size: S label Feb 3, 2020
@eclarke1 eclarke1 added this to the Sprint 17 milestone Feb 12, 2020
@aaemnnosttv aaemnnosttv self-assigned this Feb 14, 2020
@felixarntz felixarntz assigned aaemnnosttv and unassigned felixarntz Feb 19, 2020
@felixarntz felixarntz assigned aaemnnosttv and unassigned felixarntz Feb 19, 2020
@felixarntz felixarntz removed their assignment Feb 20, 2020
@tofumatt tofumatt self-assigned this Feb 24, 2020
@tofumatt
Copy link
Collaborator

@tofumatt tofumatt commented Feb 25, 2020

QA ✅

Using paired mode I got the second container select and ID to appear in setup (not pictured, but it worked as expected), settings view, and settings edit:

Screenshot 2020-02-25 21 13 10

Screenshot 2020-02-25 21 13 53

@tofumatt tofumatt removed their assignment Feb 25, 2020
@felixarntz felixarntz closed this Feb 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
8 participants