Excluding all logged in users from Analytics results in invalid JSON in Web Stories preview debug mode
See original GitHub issueBug Description
1.) When you enable the option to exclude all logged in users from Analytics in Site Kit by Google, Story passes AMP validator, but Story’s debug mode in the story preview is outputting the below warning
Steps to reproduce
- Go to Site Kit settings
- Click on edit Analytics > Exclude from Analytics all logged-in users
- Go to Web Stories
- Open in editor > preview a story
- See debug tab and notice invalid JSON error
Screenshots
Additional Context
Related Github issue https://github.com/google/web-stories-wp/issues/7939
- PHP Version:
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari] chrome
- Plugin Version [e.g. 22] 1.34.0
- Device: [e.g. iPhone6] macOS
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
- The GA opt-out element output for AMP should not raise any validation errors or warnings for HTML or AMP markup validation
Implementation Brief
- Merge https://github.com/google/site-kit-wp/pull/3593. See conversation on https://github.com/google/web-stories-wp/issues/7939 issue for more information
Test Coverage
- No changes
Visual Regression Changes
- N/A
QA Brief
- Set up and configure Analytics to exclude tracking for logged in users (default)
- Enable Web Stories and create a new story
- Leave blank and click Preview
- On the preview screen, click the Debug tab
- Review the results, ensure the
__gaOptOutExtension
element is not reported (there may be other validation errors/warnings not from Site Kit)
Changelog entry
- Fix AMP validation error caused by the GA opt-out snippet conditionally placed by Site Kit.
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
How to Fix the Invalid JSON Error in WordPress? - Rank Math
In this article, learn how to fix the invalid JSON error - 'Updating failed. The response is not a valid JSON response.' with...
Read more >How to Fix the Invalid JSON Response Error in WordPress
One of the most common causes of the invalid JSON response error is an issue with your site's .htaccess file and/or WordPress permalinks....
Read more >How to Stop Google Analytics from Tracking Logged In ...
Automatically Exclude Logged-In Users from Tracking (Easy Way). There're many ways to stop tracking WordPress admin visits in Google Analytics.
Read more >How to Fix The Invalid JSON Error in WordPress (Beginner's ...
Here's our step by step guide on how to fix the invalid JSON ... After that, WordPress will keep a log of all...
Read more >failed to install with npm, invalid json response - Stack Overflow
Viral Patel comment solved it for me. Problem was solved by cleaning the local cache with. npm cache clean --force.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@wpdarren actually, sorry, it should be good – I just tested this again and while there are errors that show Site Kit, it’s mostly because the output is minified and line 6 starts with our opt-out comment there which is normal. The main error we don’t want to see is the first one in your screenshot there about invalid JSON.
Here’s what I see
QA Update: Pass ✅