Adwords conversion tracking in OpenCart

lisa Lisa, 18th January 2013

How do you add conversion tracking to OpenCart when it has a shared success page?

A client asked me to add some Google Adwords conversion tracking code to their OpenCart website's success page that is shown after someone completes an order.

However, OpenCart doesn't have one file for that - it has catalog/view/theme/xxx/template/common/success.tpl which acts as a success page for everything that needs a success message on the site - such as the contact form for example. And it would skew your results if everytime someone sent you a contact message Adwords thought you'd converted a sale!

But thanks to a tip from storm-cloud on the OpenCart support forum, I think I've worked around it.

You just need to wrap some PHP around the tracking code, telling it to only show / be counted if the success message is the result of a sale. That PHP is:

<?php if (isset($this->request->get['route']) && $this->request->get['route'] == 'checkout/success') { ?>

<!-- tracking code goes here -->

<?php } ?>

Personally I put all of this just above:

  <?php echo $content_bottom; ?></div>

Google says to make sure it's within body tags.

Since uploading that, I've sent a test message from the contact page, viewed the source of the success message, and not been able to see the tracking code. And placed a test order, viewed the source of the success message, and been able to see the tracking code. So whilst I'm awaiting to hear back from the people checking my client's Adwords account, all seems to be OK!

If you wish to track something other than completed purchases - perhaps account sign ups - then  you need to change 'checkout/success' accordingly.

Want to share? Tweet it!

More from our blog

5 ways we've used the web to combat the challenges of 2020

5 ways we've used the web to combat the challenges of 2020

24.09.20

2020 has certainly been a very different sort of year. We've been thankful that for us - despite the team all working from home -… Read →

The 18a orchard in full bloom

The 18a orchard in full bloom

18.08.20

Over a decade ago we planted a small fruit orchard at Tom's parents house, planting a tree for every website we built in our first… Read →

Tom shortlisted for Agri-tech Innovator of the Year 2020

Tom shortlisted for Agri-tech Innovator of the Year 2020

14.08.20

We are very excited to be able to announce that 18a's CTO Tom Freeman has been shortlisted for the British Farming Awards' Agri-tech Innovator of… Read →