-
Notifications
You must be signed in to change notification settings - Fork 295
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
Fix AMP validation when tracking is disabled #1252
Merged
Merged
Changes from 9 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
95a2cc1
Don't print amp-analytics if tracking disabled.
aaemnnosttv 74f5d47
Don't output tracking opt-out in AMP context.
aaemnnosttv 34a945a
Update no-js selector to exclude valid amp contexts.
aaemnnosttv 8c26d3a
Add optoutElementId to amp analytics config.
aaemnnosttv 20d520b
Update tracking opt out for AMP compatibility.
aaemnnosttv f2af477
Remove guard to rely on opt-out in AMP again.
aaemnnosttv a89657a
Replace meta as opt-out element with plain script.
aaemnnosttv bb9ed73
Simplify printing tracking opt out.
aaemnnosttv edded94
Use application/ld+json as type for now.
aaemnnosttv 8328b65
Remove irrelevant todo comment.
aaemnnosttv 17e7019
Set optoutElementId at top level.
aaemnnosttv 8e30592
Add support for optoutElementId to AMP Tag Manager snippet.
felixarntz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,7 @@ | |
} | ||
} | ||
|
||
.no-js { | ||
.no-js:not([amp-version]) { | ||
|
||
[id^="js-googlesitekit-"] { | ||
display: none; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -384,12 +384,13 @@ protected function print_amp_gtag() { | |
'vars' => array( | ||
'gtag_id' => $tracking_id, | ||
'config' => array( | ||
$tracking_id => array( | ||
$tracking_id => array( | ||
'groups' => 'default', | ||
'linker' => array( | ||
'domains' => array( $this->get_home_domain() ), | ||
), | ||
), | ||
'optoutElementId' => '__gaOptOutExtension', | ||
), | ||
), | ||
); | ||
|
@@ -1273,7 +1274,11 @@ private function get_home_domain() { | |
private function print_tracking_opt_out() { | ||
?> | ||
<!-- <?php esc_html_e( 'Google Analytics user opt-out added via Site Kit by Google', 'google-site-kit' ); ?> --> | ||
<script type="text/javascript">window["_gaUserPrefs"] = { ioo : function() { return true; } }</script> | ||
<?php if ( $this->context->is_amp() ) : // TODO: update script type to `text/plain` when supported by AMP plugin. ?> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's remove the comment here per ampproject/amp-wp#4392 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I suppose that is no longer relevant 😄 Done! |
||
<script type="application/ld+json" id="__gaOptOutExtension"></script> | ||
<?php else : ?> | ||
<script type="text/javascript">window["_gaUserPrefs"] = { ioo : function() { return true; } }</script> | ||
<?php endif; ?> | ||
<?php | ||
} | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has to be on the top-level, together with
vars
. See e.g. https://github.com/ampproject/amphtml/blob/b0aff1b9a59d3ca8f10a6ebe4d6eaeda8c826e61/extensions/amp-analytics/0.1/vendors/googleanalytics.json#L65