Hello,
I am trying to add Google Analytics and Ads to a website, and I am stumbling on an issue where the Ads tag is sending conversion hits for many interactions for which I am not using any code to track.
For example, I am getting conversion hits on ‘config’ that happens during page load, ‘form_start’, ‘form_submit’ for forms that I am not tracking and more. My code:
// inside website's <head>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('consent', 'default', {
'ad_storage': 'denied',
'ad_user_data': 'denied',
'ad_personalization': 'denied',
'analytics_storage': 'denied'
});
</script>
<script id="gtag" async src="https://www.googletagmanager.com/gtag/js?id=<?= $site->gtag() ?>"></script>
<script>
gtag('js', new Date());
gtag('config', '<?= $site->gtag() ?>'); // Google tag
gtag('config', '<?= $site->awtag() ?>'); // Google ads tag
</script>
The only form I want to track has the following code in the success handler:
if (form.dataset.track === 'true') {
gtag('event', 'conversion', {
'send_to': 'AW-xxxxxx/xxxxxxxxx',
})
}
This is my first time integrating these things. Any ideas about what is wrong?