Jump to content
Keepsake

Current ShareASale integration

Recommended Posts

Hi guys

I'm on 1.6.0.14 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 -->
{literal}
<script>
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}
	shareasaleSSCID&&shareasaleSetCookie("shareasaleSSCID",shareasaleSSCID,94670778e4,"/");
	</script>
{/literal}
	

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);
        $this->context->smarty->assign(array(
            'products_total'=>$order->total_products,
        ));
        $this->setTemplate(_PS_THEME_DIR_.'order-confirmation.tpl');
	

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,
Mike
RedlineGoods.com

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

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