Implementation of AffilBox into OpenCart

Datum přidání14. 04. 2012
AutorKateřina Střelcová
Implementation of AffilBox into OpenCart

Today we have a tutorial on how to implement AffilBox into the popular opensource e-shop system OpenCart.

Before deploying the codes, create a subdomain for your commission program.
This will give you both a tracking and conversion code in the shape of your domain, and you will have a higher order tracking success rate.

Implementation of tracking code

The tracking code tracks incoming visitors and stores a cookie to later identify and match them to the partner that brought them in.

The tracking code looks something like this:

[sourcecode language=”javascript”]
<script src=”http://demo.affilbox.cz/js/module/tracking.js”></script>
<script>// <![CDATA[
var affilate=’http://demo.affilbox.cz/’;
var advertiser = 1;
var campaign = 1;
tracking();
// ]]<</script>
/sourcecode]

The specific code for your campaign can be found when you view the ad campaign. In the left menu of your AffilBox license, click Advertising Campaigns.

Expand your campaign and select Codes from the top menu:

Place this code in /catalog/view/theme/default/template/common/header.tpl, or footer.tpl. (If you are using a template other than the base template, replace the default folder with the name of your template)

Conversion code implementation

The conversion code takes care of recording the conversion and its value. You can find it in your AffilBox license in the same place as the tracking code.

To implement it correctly, we need to take a few steps.

1) In catalog\controller\checkout\confirm.php around line 419 is the line:

[sourcecode language=”php”]
<strong>$this->data[‘totals’] = $total_data;</strong>
[/sourcecode]

add below it:

[sourcecode language=”php”]
$this->session->data[‘ab_total’] = $total_data;
[/sourcecode]

2) In catalog\controller\checkout\success.php around line 10 is:

[sourcecode language=”php”]
if (isset($this->session->data[‘order_id’])) {
/sourcecode]

Then below that line, insert

[sourcecode language=”php”]
$this->data[‘ab_orderid’] = $this->session->data[‘order_id’];
$this->data[‘ab_total’] = $this->session->data[‘ab_total’];
[/sourcecode]

3) Finally, you need to add (and replace the URL with the address of your instance) to the catalog\view\theme\default\template\common\success.tpl confirmation template:

[sourcecode language=”php”]
<!–?php <br ?–>if(isset($ab_total) & isset($ab_orderid)) {
?>
<iframe src=”http://c656.affilbox.cz/konverze/aid/3/kid/1/cena/<?php echo $ab_total[0][‘value’]; ?>/transaction/<?php echo $ab_orderid; ?>/” width=”1″ height=”1″ frameborder=”0″ scrolling=”no”></iframe>
<!–?php } ?–>
[/sourcecode]

That’s it!

If you need help with anything, you can contact us anytime and we will be happy to help and advise you.

Leave a comment

Your email address will not be published. Required information is marked with *