In an attempt to implement Google Tag Manager, we have followed the implementation recommended by the NextJS developers at https://github.com/vercel/next.js/tree/canary/examples/with-google-tag-manager.
However, within some services connected through GTM (Google Analytics, Google AdWords, Bing Ads, etc.), I am noticing discrepancies. Most noticeably, my AdWords clicks and Analytics sessions have a large discrepancy from one another. Google AdWords seems to be tracking all clicks correctly, but Google Analytics is not picking up all sessions. This number is off by ~35-40%.
Based on the data, it would seem that my GTM tags are sometimes not firing. However, through the use of multiple Tag Assistant browser extensions as well as the Google Tag Manager preview mode, I am always able to see my tags firing when expected when testing.
Additionally, Google Analytics occasionally throws a group of notifications with errors reading:
The Ad Destination URL https://www.x from the AdWords account x has accrued a significant number of clicks but a lower-than-expected number of sessions because the page is not tagged with a supported version of the Google Analytics tracking code.
If your pages do not include a supported version of the Analytics tracking code, then Analytics cannot collect data for those pages.
To find the right tracking code for your property, on the Analytics Admin page in the Property column, click Tracking info, then click Tracking Code.
Google Tag Assistant Recordings can help you ensure that your tracking code is sending hits as expected.
When visiting the links provided in the notifications, I am able to see my GTM + UA code firing without fail with any browser or device I visit it on. When I suggest Google "check again," with the specific links, a few days later they are marked as resolved, and a new group of notifications with different links and the same message appears.
I have even contacted Google's GTM support, and they've reported that they are unable to see any errors, both in the tagging present on my site, as well as the Analytics account configuration.
I am at a complete loss and would appreciate any suggestions or insight. Thanks.
The issue ended up being related to Content Security Policy. Some browsers (namely Safari) were rejecting the GTM script insertion, causing it to not fire on iOS and MacOS. The solution was to simply add the relevant urls into the CSP header in the script section. Such a simple solution for something that has given me a headache for weeks.