Reputation: 1
I have integrated Google Ads conversion tracking in my AngularJS application. I have two simple conversion events that are being added to the DOM dynamically, each on a different page. Both of them are added to the DOM like this, depending on the url of the page:
if (toParams.key === 'example-page') {
if (!document.getElementById('thankYouConversionScript')) { // Check if script doesn't already exist
var refElement = document.getElementById('phoneScript');
if (refElement) {
var inlineScript = document.createElement('script');
inlineScript.id = 'thankYouConversionScript'; // Assign ID to the script
inlineScript.text = 'gtag(\'event\', \'conversion\', {"send_to": "AW-xxxxxxx/xxxxxxxxxxxx"});';
refElement.parentNode.insertBefore(inlineScript, refElement.nextSibling);
}
}
}
When testing the system using the Google Tag Assistant(legacy) I noticed a weird behaviour. The first time the script is added to the page, it fires correctly. However, after navigating to the other page, where the second script is added to the DOM, the Google Tag Assistant shows both the new conversion event as well as the the old one. When testing the system with the modern Tag Assistant, everything seems to be okay - only one new conversion event is added.
I have tried removing the scripts from the dom when navigating to another page, but the list still shows both conversion events.
Is this just an issue with legacy Google Tag Assistant or am I doing something wrong?
Upvotes: 0
Views: 132