Implement Q Pixel in Opencart
  • 29 Mar 2024
  • 1 Minute to read
  • Contributors
  • Dark
    Light

Implement Q Pixel in Opencart

  • Dark
    Light

Article summary

A comprehensive tagging strategy sets your campaign up for success and provides robust audience insights. The following instructions walk you through the process for placing Q Pixels for advanced conversion tracking in Opencart.


đź’ˇ Reminder:

  • Do not alter the code. Any edits to the code may result in the tag not firing.

  • The tag does not interfere with your page load because it is asynchronous (it loads in the background). See Get Started with Quantcast Tagging for more technical details.  

⚠️ What you need to continue:

Q Pixel (tag code available in the Quantcast Platform on the Q Pixel page)

Grab_Q_Pixel

Q Pixel in Opencart

  1. Open the success.php file found in /catalog/controller/checkout/success.php

  2. Copy the following 2 lines:

$this->session->data['AddShoppersAmount'] = $this->cart->getTotal();

$this->session->data['AddShoppersOrderID'] = $this->session->data['order_id'];
  1. Paste the two copied lines immediately after the line that reads:

“if (isset($this->session->data['order_id'])) {"
  1. Open the success.tpl file found in /catalog/view/theme/default/template/common/success.tpl

You will find the two lines of code that were just pasted here.

  1. Update the "qacct" field in the code with your Quantcast p-code.  You can find the location for this code in the account code snippet below.

 <script type=”text/javascript”>
    window._qevents = window._qevents || [];
    (function() {
        var elem = document.createElement('script');
        elem.src = (document.location.protocol == "https:" ? "https://secure" : "http://edge") + ".quantserve.com/quant.js";
        elem.async = true;
        elem.type = "text/javascript";
        var scpt = document.getElementsByTagName('script')[0];
        scpt.parentNode.insertBefore(elem, scpt);
    })();

     window._qevents.push({

        "qacct": "p-xxxxxxxxxxxxx",
        "labels": "_fp.event.PageView, _fp.event.Purchase"
        "orderid": "AddShoppersOrderID",
        "revenue": "AddShoppersAmount",
        "event": "refresh"
    });
</script>

6. Paste the updated script into the “success.tpl” file and save.

Verify tag implementation using the Quantcast Tag Inspector

The Quantcast Tag Inspector is a Google Chrome plugin that checks whether your Quantcast Tag and Audience Segments are implemented correctly. Install the Inspector to review individual pages of your site, and make sure the audience segments are firing correctly. For more information, see the Inspect Your Tag help document.

You are done! Please check the Q Pixel app to confirm that your tags are collecting data. If you are not seeing any activity, reach out to [email protected] or submit a Help Center request at www.quantcast.com.  For more information on tagging, see our Tagging Overview article.


Was this article helpful?

Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.
ESC

Q, facilitating knowledge discovery through conversational intelligence