2

I have an issue with the Magento Google Analytics module on one site I have developed.

I have checked the code and compared to another site that I know works.

$this->getOrderIds() in getOrdersTrackingData() of ga.php appears to always be blank regardless of what I do.

I have manually added a real order id and this gets the data from the database and outputs it to the block correctly.

I have determined that the $orderIds variable has the correct data in

SetGoogleAnalyticsOnOrderSuccessPageViewObserver.php 

I am at a loss as to why this would not be work anyone one got any ideas?

6
  • Do you use third party checkout module?
    – Sohel Rana
    Mar 8, 2018 at 16:50
  • Sohel, thanks for replying. No, we are using the standard one page checkout within Magento. The only plugin we are using is the SagePaySuite from Ebizmarts.
    – Dan
    Mar 8, 2018 at 16:51
  • Just a quick "dummy-check", do you have GA enabled in Admin->Stores->Configuration->Sales->Google API->Google Analytics? Also, do you have the correct Account Number entered?
    – mtr.web
    Mar 8, 2018 at 21:13
  • Analytics is collecting data fine for page views and on the correct account. The only thing that is missing is the order data due to the OrderIds array being empty. If I set the array manually, the data is returned for the order specified. Strange one!
    – Dan
    Mar 8, 2018 at 21:52
  • @Dan Did you get to the bottom of this? ordersTrackingData = [] is always empty What your finding can you share please? thanks. Jul 3, 2018 at 16:07

2 Answers 2

1

@Dan

There is an Bug on This File

/vendor/magento/module-google-analytics/view/frontend/web/js/google-analytics.js

It can't check the length of an object therefore you can check currency property like so:

if (config.ordersTrackingData.hasOwnProperty('currency')) 

bug fix ref: https://github.com/magento/magento2/commit/24a5abd95a177d9e21f5c2791931e6d104be42aa

-1

Sometimes this type of issue occurs because of "Cookie Restriction Mode". So, please select "No" if you selected "Yes" for it. Try this if it may help you. Please refer the following screenshot....

enter image description here

1
  • 1
    Please add a reason on down voting. Just voting down is not very helpful.
    – Akif
    Sep 17, 2020 at 15:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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