Integrating with OpenCart

Out-of-the-box features:
  • Conversion tracking
  • Commission based on order amount
  • Track affiliate coupon code conversions
  • Supports lifetime commissions
  • Auto-handle recurring commissions
  • Auto-handle refunds and disputes

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

  1. In your Opencart Admin, go to Design > Theme Editor > Common > header.twig. Just before the closing </head> tag add the following code:

    <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>
    

    {{{{NO_ACCOUNT_ID_SET_MESSAGE}}}}

    Hit save.

  2. Next, go to Design > Theme Editor > Common > success.twig. Add the following code just 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 %}
    

    {{{{NO_ACCOUNT_ID_SET_MESSAGE}}}}

  3. Lastly, on your server, find catalog/controller/checkout/success.php add the following code 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, and you’re done!

Important

Please remember to test a conversion before starting your program. This way you can verify that tracking has been set up correctly. You can create a test conversion by following the steps described here.

Start a 14-day free trial with all our features enabled