Jump to content

Current ShareASale integration

Recommended Posts

Hi guys

I'm on and I've integrated ShareASale's current tracking pixel - the one that requires a cookie, explained at http://shareasale.com/itp/custom.htm#_Mastertag_Installation_Instructions

Here's how - and again it's a mix of own code and code from Vekia and others from several threads on here back from 2013.

First, to do the cookie, paste this in header.tpl for your template - notice how it's all wrapped in LITERAL clauses otherwise you get http 500.

	<!-- ShareASale - wrapped in literal because otherwise Smarty fails -->
var shareasaleSSCID=shareasaleGetParameterByName("sscid");
	function shareasaleSetCookie(e,a,r,s,t){if(e&&a){var o,n=s?"; path="+s:"",i=t?"; domain="+t:"",l="";r&&((o=new Date).setTime(o.getTime()+r),l="; expires="+o.toUTCString()),document.cookie=e+"="+a+l+n+i}}
function shareasaleGetParameterByName(e,a){a||(a=window.location.href),e=e.replace(/[\[\]]/g,"\\$&");var r=new RegExp("[?&]"+e+"(=([^&#]*)|&|#|$)").exec(a);return r?r[2]?decodeURIComponent(r[2].replace(/\+/g," ")):"":null}

Then, using approach from the forums, I added extra variable to /controllers/front/OrderConfirmationController.php

	        $order = new Order($this->id_order);
        $cart = new Cart($order->id_cart);

Replace the last row (setTemplate) with the 6 rows including the last one. There are samples in the historical threads as how to get more variables - I only needed the order total without tax.

Then in order-confirmation.tpl add the following to the end:

	<img id="_SHRSL_img_1" src="https://www.shareasale.com/sale.cfm?tracking={Tools::getvalue('id_order')}&amount={$products_total}&merchantID=XXXX&transtype=sale&sscidmode=6&sscid={$smarty.cookies.shareasaleSSCID}" width="1" height="1">
<script defer async type="text/javascript" src="https://shareasale-analytics.com/j.js"></script>

Make sure to change your merchantID to the correct one.

Hope that helps you guys - took a chunk out of my day to figure it out since I never did Presta/Smarty programming before.

Have a great day,

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More