I also had the same issue and was able to resolve this. I believe it is related to the cookie policy.
If you open your home page in incognito mode, and, before accepting the cookie, right click on the page in Chrome and select "View Page Source". You can then search (with Ctrl + F) for "gtag" and it will likely not show up. If you go back to the home page and then accept the cookies it will show up in the source.
Google analytics will "see" the unaccepted page and the Google tags are not exposed. This is due to this line in the Main Layout view:
t-if="website and website.google_analytics_key and request.env['ir.http']._is_allowed_cookie('optional') and not editable"
It will not show the Analytic tag if cookies are not allowed.
I think it would be good if the Odoo team allows this when the page visitor is a bot versus a person.
If you are not worried about potential privacy issues, you can add your own tag. I added mine in the "Custom Code Layout"
view:
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'AW-11128496214');
window.addEventListener('load', function() {
if (document.location.href.includes('/contactus-thank-you')) {
gtag('event', 'conversion', {
'send_to': 'AW-11128496214/7hWJCPyjzZkYENbAvbop'
});
}
});
Replace AW-11128496111 with your tag in the two locations
Note: You may need to add language to your Privacy Policy to make sure you are compliant with Google and privacy regulations.
Having same issue, did you resolve?
Owner
WiderView Visual Media
Mob: 07934 403341
E-Mail: chris@widerview-visual.media