Google Analytics missing users from Ads
-
Hello,
Google Analytics (UA / G4A) does not show 90% of users who came from Google Ads campaigns. We have this on several sites.
After checking the campaigns, I suspect that if all scripts and cookies are enabled, a hit will not be sent to Google Analytics and therefore the traffic is considered as “direct” or missing completely, cause it’s one-page website and there is no user action / page reload needed.
Is my suspicion correct?
Thank you for info.
-
Actually that can be a problem since Google Analytics needs to start tracking visitors when they arrive on the site, which is illegal. And when the visitor accepts being tracked (if they do) their referrer is no longer the ad, but direct.
I see.
Theoretically, this could be hooked up to https://developers.google.com/tag-platform/devguides/consent#gtag.js consent status and passed on only with users consent.
Sounds like a good idea!
If you get it working @mypixels , could you document that so that I can add that to the FAQ?
So far, I have only prepared a rough prototype for testing purposes.
I would appreciate feedback from someone with technical experience with Google Analytics. My specialization lies elsewhere than GA / GTM and JS. I’m not sure if I understood everything correctly, but it seems that the parameters are not passed ?? From what I see Google Tag Assistant does not report problems and cookies are not stored until you agree with that.
The prerequisite for functionality is the correctly set consent settings in GTM https://support.google.com/analytics/answer/9976101 and the addition of GTM / Analytics among the always allowed scripts.
<script> // Define dataLayer and the gtag function. // https://developers.google.com/tag-platform/devguides/consent window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('set', 'url_passthrough', true); gtag('set', 'ads_data_redaction', true); gtag('consent', 'default', { 'ad_storage': 'denied', 'analytics_storage': 'denied', 'wait_for_update': 500, }); // Check if cookie exists // modified https://www.w3schools.com/js/js_cookies.asp function checkCookie(cname) { let username = getCookie(cname); if (username != "") { return true; } else { return false; } } // Get cookie // umodified https://www.w3schools.com/js/js_cookies.asp function getCookie(cname) { let name = cname + "="; let decodedCookie = decodeURIComponent(document.cookie); let ca = decodedCookie.split(';'); for(let i = 0; i <ca.length; i++) { let c = ca[i]; while (c.charAt(0) == ' ') { c = c.substring(1); } if (c.indexOf(name) == 0) { return c.substring(name.length, c.length); } } return ""; } // Check if cookie from plugin "Cookies and Content Security Policy" exists if (checkCookie('cookies_and_content_security_policy') == true) { consent_cookie = getCookie('cookies_and_content_security_policy'); if (consent_cookie.includes("statistics")) { // Google Analytics allowed gtag('set', 'ads_data_redaction', false); gtag('consent', 'update', { 'ad_storage': 'granted', 'analytics_storage': 'granted', // 'functionality_storage': 'granted', // 'personalization_storage': 'granted', // 'security_storage': 'granted', }); } else { // Google Analytics disallowed gtag('set', 'ads_data_redaction', true); gtag('consent', 'default', { 'ad_storage': 'denied', 'analytics_storage': 'denied', }); } } else { // Cookie from plugin "Cookies and Content Security Policy" doesn't exists } </script>
Looks good! Has it been tested?
I don’t currently have enough traffic to experiment on this. For now, it seems like a working solution, but I can’t say for sure.
In the example above, there is an error regarding disabled parameter passing.
I am currently looking for someone more experienced who will help me validate the solution ??
<script> // Define dataLayer and the gtag function. // https://developers.google.com/tag-platform/devguides/consent window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('consent', 'default', { 'ad_storage': 'denied', 'analytics_storage': 'denied', 'wait_for_update': 500, }); gtag('set', 'url_passthrough', true); gtag('set', 'ads_data_redaction', false); // Check if cookie exists // modified https://www.w3schools.com/js/js_cookies.asp function checkCookie(cname) { let username = getCookie(cname); if (username != "") { return true; } else { return false; } } // Get cookie // umodified https://www.w3schools.com/js/js_cookies.asp function getCookie(cname) { let name = cname + "="; let decodedCookie = decodeURIComponent(document.cookie); let ca = decodedCookie.split(';'); for(let i = 0; i <ca.length; i++) { let c = ca[i]; while (c.charAt(0) == ' ') { c = c.substring(1); } if (c.indexOf(name) == 0) { return c.substring(name.length, c.length); } } return ""; } // Check if cookie from plugin "Cookies and Content Security Policy" exists if (checkCookie('cookies_and_content_security_policy') == true) { consent_cookie = getCookie('cookies_and_content_security_policy'); if (consent_cookie.includes("statistics")) { // Google Analytics allowed gtag('set', 'ads_data_redaction', false); gtag('consent', 'update', { 'ad_storage': 'granted', 'analytics_storage': 'granted', // 'functionality_storage': 'granted', // 'personalization_storage': 'granted', // 'security_storage': 'granted', }); } else { // Google Analytics disallowed gtag('set', 'ads_data_redaction', true); gtag('consent', 'default', { 'ad_storage': 'denied', 'analytics_storage': 'denied', }); } } else { // Cookie from plugin "Cookies and Content Security Policy" doesn't exists } </script>
- The topic ‘Google Analytics missing users from Ads’ is closed to new replies.