Integrating with OpenCart

  1. In catalog/view/theme/*/template/common/footer.twig just before the closing </body> 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))))');
        tap('detect');
    </script>
    

    {{{{NO_ACCOUNT_ID_SET_MESSAGE}}}}

  2. Next, in catalog/controller/checkout/success.php add the following code just before $this->response->setOutput($this->load->view('common/success', $data));:

        if (isset($this->session->data['success_order_id'])) {
            $this->load->model('checkout/order');
            $order_data = $this->model_checkout_order->getOrder($this->session->data['success_order_id']);
    
            $orderDetails = array(
                "id" => $order_data['order_id'],
                "amount" => $order_data['sub_total'],
            );
    
            $this->data['orderDetails'] = $orderDetails;
    
            unset($this->session->data['success_order_id']);
        }
    
  3. Lastly, in catalog/view/theme/*/template/common/success.twig add the following code just before {{ 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))))');
        tap('conversion', "{{ orderDetails.id }}", {{ orderDetails.amount }});
    </script>
    {% endif %}
    

    {{{{NO_ACCOUNT_ID_SET_MESSAGE}}}}

  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

Start now