I'm trying to add some google tracking scripts to onepage success.

But I'm facing a problem in this page.. the url is :


but when I click on view page source in my browser it's redirect me to another page :


Could you please help ? how I can stop this redirect ?

Please note that I'm using custom theme.

Looking forward for your quick assistance.


2 Answers 2


It's correct behavior, the system clear quote data on success page

Just for temporary development purposes you can comment clearQuote in Success action

See \Magento\Checkout\Controller\Onepage\Success

  • I will check and let you know
    – Dun7ill
    Commented Jun 27, 2022 at 16:44
  • You're right, it's works now.
    – Dun7ill
    Commented Jun 27, 2022 at 16:49

In general, you do not need to view source to add Google scripts to Magento. In the Admin area, under Stores -> Configuration, click on Sales -> Google API. There you can paste your Google Analytics Tracking ID (Usually begins with UA-.....) under the heading Account Number.

If the script is to be added only to a specific page, then you will need to Insert a JS component in the proper PHTML template.

  • No this scripts should be added only in the success page. It's related to conversions
    – Dun7ill
    Commented Jun 27, 2022 at 16:45

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.