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

Fix AMP validation when tracking is disabled #1252

Merged
merged 12 commits into from
Mar 16, 2020
Merged
2 changes: 1 addition & 1 deletion assets/sass/components/global/_googlesitekit-noscript.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
}
}

.no-js {
.no-js:not([amp-version]) {

[id^="js-googlesitekit-"] {
display: none;
Expand Down
9 changes: 7 additions & 2 deletions includes/Modules/Analytics.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

),
),
);
Expand Down Expand Up @@ -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. ?>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove the comment here per ampproject/amp-wp#4392

Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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
}

Expand Down