Hi All,
I’ve successfully implemented the Google Ads global site tag (gtag.js) on all relevant pages using Adobe Launch. I verified that gtag.js is loading correctly, and I can see console logs confirming it's working on page load.
Now, I’m trying to track a Google Ads conversion when a user clicks a specific button. I created a rule in Adobe Launch with the following setup:
Event: Core - Click - with the correct CSS selector
Action: Core - Custom Code (JavaScript)
Here’s the code I used in the action:
function gtag_report_conversion() {
var callback = function () {
if (typeof(url) != 'undefined') {
url = window.location;
}
};
gtag('event', 'conversion', {
'send_to': 'AW-00000000000/XXXXXXXXXXX',
'value': 1.0,
'currency': 'EUR',
'event_callback': callback
});
}
gtag_report_conversion();
The rule is firing (confirmed via Adobe Launch debugger)
But the console statements are not appearing
No conversion hits are seen in Omnibug or DevTools > Network
It seems like the custom code is not executing even though the rule is triggered
Can someone help identify what might be going wrong? Is there an issue with how the custom code is written or executed within the Launch rule?
Thanks in advance for your guidance!
Solved! Go to Solution.
Hi,
I use custom code to fire Google Conversion codes, so I know this isn't a limitation in Launch.
So, let's try and figure out what is failing in your implementation.
The code you are using looks strange though...
This is the code I use:
// Config gtag
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('config', 'AW-00000000000');
gtag('event', 'conversion', {
'send_to': 'AW-00000000000/XXXXXXXXXXX',
'transaction_id': '122345'
});
You don't really need to wrap your code in a function, adding the code directly in custom code works just fine... but I think the main issue is that you are missing the account configuration line, and I don't see any "push" to the dataLayer.
So, you are passing value and currency, but not a transaction id.. so taking my code, and your needs, try using:
// Config gtag
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('config', 'AW-00000000000');
gtag('event', 'conversion', {
'send_to': 'AW-00000000000/XXXXXXXXXXX',
'value': 1.0,
'currency': 'EUR'
});
(replace the account id and conversion label as per your needs)
Hi,
I use custom code to fire Google Conversion codes, so I know this isn't a limitation in Launch.
So, let's try and figure out what is failing in your implementation.
The code you are using looks strange though...
This is the code I use:
// Config gtag
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('config', 'AW-00000000000');
gtag('event', 'conversion', {
'send_to': 'AW-00000000000/XXXXXXXXXXX',
'transaction_id': '122345'
});
You don't really need to wrap your code in a function, adding the code directly in custom code works just fine... but I think the main issue is that you are missing the account configuration line, and I don't see any "push" to the dataLayer.
So, you are passing value and currency, but not a transaction id.. so taking my code, and your needs, try using:
// Config gtag
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('config', 'AW-00000000000');
gtag('event', 'conversion', {
'send_to': 'AW-00000000000/XXXXXXXXXXX',
'value': 1.0,
'currency': 'EUR'
});
(replace the account id and conversion label as per your needs)
Views
Likes
Replies