Adobe rule not pushing custom variable data in Google Ads | Community
Skip to main content
July 18, 2024
Solved

Adobe rule not pushing custom variable data in Google Ads

  • July 18, 2024
  • 1 reply
  • 464 views

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>

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by bjoern__koth

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.

1 reply

bjoern__koth
Community Advisor and Adobe Champion
bjoern__kothCommunity Advisor and Adobe ChampionAccepted solution
Community Advisor and Adobe Champion
January 9, 2025

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!