I am trying to figure out how to get Google Ad conversion tracking working in Magento 2.3.5 - the Google Ad API setting isn't available under admin area of this version. Universal Tracking Code already installed on every page.

So far I've added the following to the success.phtml file:

$OrderId = Mage::getSingleton('checkout/session')->getLastOrderId();
$Order = Mage::getModel('sales/order')->load($OrderId);
$incrementId = $Order->getIncrementId();

<!-- Event snippet for Purchase conversion page -->
  gtag('event', 'conversion', {
      'send_to': 'AW-XXXXXXXX/XXXXXXXXXXX',
      'value': <?php echo number_format($Order->getSubtotal(),2,".",""); ?>,
      'currency': 'GBP',
      'transaction_id': <?php echo "'".$incrementId."'"; ?>

I think the above code may work for Magento 1. Can anyone suggest an update for Magento 2?

  • Do have any custom module in your magento ? default Adword code does not have transaction_id from block class. – Pawan Nov 6 '20 at 12:53
  • I've had to use the script above myself, as the 'Adword' section does not appear in the Magento admin (Store > Configuration > Sales > Google API) of this 2.3.5 store. – YorkieMagento Nov 6 '20 at 14:14

Magento Devdocs Google AdWords

<!-- Google Code for Back to School Sale Conversion Page -->
   <script type="text/javascript">
   /* <![CDATA[ */
   var google_conversion_id = 999999999;
   var google_conversion_language = "en";
   var google_conversion_format = "3";
   var google_conversion_color = "ffffff";
   var google_conversion_label = "MlEYCOKBnGoQz6CZoAM";
   var google_remarketing_only = false;
   /* ]]> */

   <script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js">
   <div style="display:inline;">
   <img height="1" width="1" style="border-style:none;" alt="" src="//www.googleadservices.com/pagead/conversion/872829007/?label=MlEYCOKBnGoQz6CZoAM&amp;guid=ON&amp;script=0"/>

  • Add that in success.phtml do you think? With the relevant conversion id? – YorkieMagento Nov 6 '20 at 14:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.