Expand my Community achievements bar.

Join us on September 25th for a must-attend webinar featuring Adobe Experience Maker winner Anish Raul. Discover how leading enterprises are adopting AI into their workflows securely, responsibly, and at scale.
SOLVED

Adobe rule not pushing custom variable data in Google Ads

Avatar

Level 1

I have the Google adwords event snippet implemented in an rule, but of the 4 custom variables listed in the code, only 1 of them passes back data in Google Ads - do you know why this is? The only successful variable passing back data is "var regionName" - the 3 unsuccessfully passing any data back are "var transactionID", "var order", "var currencyCode" - I don't know why this is.


Code pasted below:

 

<!-- Event snippet for Transaction conversion page -->
<script>
try {
// Directly extract product price from the page element
var priceElement = document.querySelector('.amount .price'); // Adjust selector based on your HTML structure
if (!priceElement) {
throw new Error("Price element not found on the page.");
}
var productPriceText = priceElement.textContent.trim();
var productPrice = parseFloat(productPriceText.replace(/[^\d.-]/g, ''));
if (isNaN(productPrice)) {
throw new Error("Unable to extract valid product price.");
}

// Data element for the currency code
var currencyCode = (_satellite.getVar('ACDL - currency code') || _satellite.getVar('ACDL - storefront').storeViewCurrencyCode).toLowerCase(); // Convert to lowercase

// Data element for the transaction ID
var order = _satellite.getVar('ACDL - order');
var transactionID = order ? order.orderId.toString() : '';

// Data element for the region name
var regionName = (_satellite.getVar('ACDL - storefront').websiteCode || '').toLowerCase();

// Sending the conversion event to Google Ads using gtag
gtag('event', 'conversion', {
'send_to': 'AW-963991755/2T-CCK3prVYQy7HVywM',
'value': productPrice,
'currency': currencyCode,
'transaction_id': transactionID,
'region_name': regionName // Adding region name as a custom variable
});

console.log("Google Ads conversion event sent successfully.");
} catch (error) {
console.error("Error sending Google Ads conversion event:", error.message);
}
</script>

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @HarpreetLo 

when using the Adobe Client Data Layer and trying to access data element which may be set based on a push to the ACDL, always send the event as second parameter.

_satellite.getVar('ACDL - storefront', event);

As a matter of fact, I would always send it with any getVar call, at least I have not seen an occasion when it caused problems.

Cheers from Switzerland!


View solution in original post

1 Reply

Avatar

Correct answer by
Community Advisor

Hi @HarpreetLo 

when using the Adobe Client Data Layer and trying to access data element which may be set based on a push to the ACDL, always send the event as second parameter.

_satellite.getVar('ACDL - storefront', event);

As a matter of fact, I would always send it with any getVar call, at least I have not seen an occasion when it caused problems.

Cheers from Switzerland!