All Collections
Integrations
Integrating with OpenCart
Integrating with OpenCart

Learn how to integrate Tapfiliate with OpenCart.

Maria avatar
Written by Maria
Updated over a week ago

Integrating Tapfiliate with OpenCart lets you track conversions and commissions based on order amounts for your online store.
โ€‹
To get started:

1. Log in to your OpenCart admin panel, navigate to Design > Theme Editor > Common > header.twig. Just before the closing </head> tag, insert the provided code snippet below and click the "Save" button.

<script src="https://script.tapfiliate.com/tapfiliate.js" type="text/javascript" async></script>

<script type="text/javascript">

(function(t,a,p){t.TapfiliateObject=a;t[a]=t[a]||function(){

(t[a].q=t[a].q||[]).push(arguments)}})(window,'tap');

tap('create', 'YOUR ACCOUNT ID', { integration: "opencart" });

tap('detect');

</script>

Be sure to replace 'YOUR ACCOUNT ID' with your actual account ID.

2. Next, proceed to Design > Theme Editor > Common > success.twig. Place the following code after {{ header }}.

<script src="https://script.tapfiliate.com/tapfiliate.js" type="text/javascript" async></script>

{% if orderDetails %}

<script type="text/javascript">

(function(t,a,p){t.TapfiliateObject=a;t[a]=t[a]||function(){

(t[a].q=t[a].q||[]).push(arguments)}})(window,'tap');

tap('create', 'YOUR_ACCOUNT_ID_HERE', { integration: "opencart" });

tap('conversion', "{{ orderDetails.id }}", {{ orderDetails.amount }});

</script>

{% endif %}

Make sure to replace 'YOUR ACCOUNT ID' with your actual account id.

3. Lastly, on your server, locate catalog/controller/checkout/success.php. Insert the provided code snippet right after $this->load->language('checkout/success');

if (isset($this->session->data['order_id'])) {

$this->load->model('checkout/order');

$order_id = $this->session->data['order_id'];

$order_data = $this->model_checkout_order->getOrder($order_id);

$sub_total = '0';

foreach ($this->model_checkout_order->getOrderTotals($order_id) as $total) {

if ($total['code'] = 'sub_total') {

$sub_total = $total['value'];

}

}

$orderDetails = array(

"id" => $order_data['order_id'],

"amount" => $sub_total,

"currency" => $order_data['currency_code'],

);

$data['orderDetails'] = $orderDetails;

}

4. Save your changes, and you're all set!

Feel free to explore our OpenCart integration guide here.

Please remember to conduct a conversion test before launching your program. This step will help you confirm that tracking has been correctly established. You can create a test conversion by following the steps described here.

Which version of OpenCart does your integration support?

This integration only supports Opencart 3. Prior versions are not supported.

Did this answer your question?