Skip to Content

New J2Commerce 6.6.5 is out. Here is everything in the release.

See What’s New
Account
Enter the email address on your account.
Forgot your username?
Enter your password.
Forgot your password?

Or continue with

Pending Public Category: Technical Support / Bugs Ticket #1007

Embedding affiliate code into the success page

This is a public ticket

Everybody will be able to see its contents. Do not include usernames, passwords or any other sensitive information.

J2Commerce

Version
J2Commerce v6

Conversation

Richard Gosler

I need to embed the following affiliate code into the order success page:

<script type="text/javascript">
window.goaffpro_order = {
number : "#1001",
total: 1000
}
if(typeof window.goaffproTrackConversion !== "undefined"){
window.goaffproTrackConversion(window.goaffpro_order)
}
</script>

1. which template do need to edit to create an override on to do this ?

2a. what values do i insert for the order number? (currently #1001)

2b. what values do i insert for the order total? (currently 1000)

 

 

Olivier Buisard Staff

Hi Richard,

I believe you should do this in the success/thank you page. That is, the confirmation view. For instance, if you were using Bootstrap, it would be

components/com_j2commerce/tmpl/confirmation/bootstrap5/default.php

You would then use the code

<?php if (!$isCancelled) : ?>
    <script type="text/javascript">
        window.goaffpro_order = {
            number : "#<?php echo (int) $order->order_id; ?>",
            total: <?php echo (float) $order->order_total; ?>
        }
        if(typeof window.goaffproTrackConversion !== "undefined"){
            window.goaffproTrackConversion(window.goaffpro_order)
        }
    </script>
<?php endif; ?>

Olivier.

Richard Gosler

I tried to create an override through Joomla's override engine but it's blocked. And the overrides accessible through J2C are only for product and category templates. Is there a way to create the override without it being overwritten during the next update ?

I get the following error message when i try to access it: 20 Joomla\Filesystem\Path::check() - Snooping out of bounds @ com_j2commerce/app_bootstrap5

Thanks.

Richard Gosler

Template overridden now.  Bug in J6.1.3 but there's a fix until J6.1.4.

 

 

Adam Melcher Staff

Richard,

Yes, that was a bug I passed along to Brian the first day it was released... very annoying to have to do anything by hand these days... lol

 

Adam

Richard Gosler

I'm embedding affiliate tracking code now for AWIN which is far more thorough. Their snippet for the success page is:

<!-- Fall-back Conversion Pixel - Mandatory -->
<img src="https://www.awin1.com/sread.img?tt=ns&tv=2&merchant=131322&amount={{order_subtotal}}&cr={{currency_code}}&ref={{order_ref}}&parts={{commission_group}}:{{sale_amount}}&vc={{voucher_code}}&ch=aw&customeracquisition={{customer_acquisition}}" border="0" width="0" height="0">

<!-- Conversion Tag - Mandatory -->
<script type="text/javascript">
//<![CDATA[ /*** Do not change ***/
var AWIN = AWIN || {};
AWIN.Tracking = AWIN.Tracking || {};
AWIN.Tracking.Sale = {};
/*** Set your transaction parameters ***/
AWIN.Tracking.Sale.amount = "{{order_subtotal}}";
AWIN.Tracking.Sale.orderRef = "{{order_ref}}";
AWIN.Tracking.Sale.parts = "{{commission_group}}:{{sale_amount}}";
AWIN.Tracking.Sale.voucher = "{{voucher_code}}";
AWIN.Tracking.Sale.currency = "{{currency_code}}";
AWIN.Tracking.Sale.channel = "aw";
AWIN.Tracking.Sale.customerAcquisition = "{{customer_acquisition}}";
//]]>
</script>

I tried swapping out the values within {{ }} for eg. <?php echo (int) $order->order_id; ?> but would just 'order_id' be preferable ?

FYI the following code has been added to just inside <body/>
<!-- Master Tag add just before the closing </body> tag -->
<script src="https://www.dwin1.com/131322.js" type="text/javascript" defer="defer"></script>

Then there is this for every page:

Server-side code: Setting cookies

<?php
function setAwc() {
if (!empty($_GET['awc'])) {
setcookie("awc",$_GET['awc'],time()+ 60 * 60 * 24 * 365,"/", "example.com", true, true);
}
}
?>

and this

<!-- Server to Server Tracking -->
https://www.awin1.com/sread.php?tt=ss&tv=2&merchant=131322&amount={{order_subtotal}}&ch=aw&parts={{commission_group}}:{{sale_amount}}&vc={{voucher_code}}&cr={{currency_code}}&ref={{order_ref}}&cks={{awc}}&customeracquisition={{customer_acquisition}}

Richard Gosler

I've sent you over the API guide (mattermost) but will still need to integrate this into the site I think.

Adam Melcher Staff

Richard,

Just like the GA4 and Facebook plugins, entering the API into the new plugin for this will take care of you so you won't have to do anything, but until then - in the confirmation page menu item in your backend , there is a tracking tab that will allow you to enter that tracking snippet and use shortcodes to provide the J2C6 order data points it needs.

 

Adam

Richard Gosler

Where will i find the confirmation page in admin ? I can't see one in any menu.

Adam Melcher Staff

You should have a confirmation page menu item created for J2Commerce - if not, then create one in a Hidden menu and you will find a tab in there that says tracking which shows you all of the available fields you can use for this exact purpose.

 

Adam

Richard Gosler

I created that page (thanks) and have added values as follows:

Master Tag add just before the closing </body> tag
<script src="https://www.dwin1.com/131322.js" type="text/javascript" defer="defer"></script>

Tracking code snippet on order confirmation page

<!-- Fall-back Conversion Pixel - Mandatory -->
<img src="https://www.awin1.com/sread.img?tt=ns&tv=2&merchant=131322&amount={{[ORDER_TOTAL]}}&cr={{[CURRENCY_CODE]}}&ref={{[ORDER_NUMBER]}}&parts={{commission_group}}:{{[ORDER_SUBTOTAL_EX_TAX]}}&vc={{voucher_code}}&ch=aw&customeracquisition={{NEW}}" border="0" width="0" height="0">

<!-- Conversion Tag - Mandatory --> 
<script type="text/javascript">
//<![CDATA[ /*** Do not change ***/
var AWIN = AWIN || {};
AWIN.Tracking = AWIN.Tracking || {};
AWIN.Tracking.Sale = {};
/*** Set your transaction parameters ***/
AWIN.Tracking.Sale.amount = "{{[ORDER_TOTAL]}}";
AWIN.Tracking.Sale.orderRef = "{{[ORDER_NUMBER]}}";
AWIN.Tracking.Sale.parts = "{{commission_group}}:{{[ORDER_SUBTOTAL_EX_TAX]}}";
AWIN.Tracking.Sale.voucher = "{{voucher_code}}";
AWIN.Tracking.Sale.currency = "{{[CURRENCY_CODE]}}";
AWIN.Tracking.Sale.channel = "aw";
AWIN.Tracking.Sale.customerAcquisition = "{{NEW}}";
//]]>
</script>

Server side cookie code also in the confirmation page but not sure if this is correct

<?php
    function setAwc() {
        if (!empty($_GET['awc'])) {
            setcookie("awc",$_GET['awc'],time()+ 60 * 60 * 24 * 365,"/", "example.com", true, true);   
     }
 }
?>

Lastly, this to all page of the site before the closing </body> tag (but i'm sure it's not right)

<?php
$url = "https://www.awin1.com/sread.php?tt=ss&tv=2&merchant=131322";
$url .= "&amount=" . [ORDER_TOTAL];
$url .= "&ch =aw";
$url .= "&cr=" . [CURRENCY_CODE];
$url .= "&ref=" . [ORDER_NUMBER];
$url .= "&parts=" . $commissionGroup . ":" . [ORDER_SUBTOTAL_EX_TAX];
$url .= "&vc=" . $voucherCode;
$url .= "&customeracquisition=" . NEW;
if (isset($awc)) {
$url .= "&cks=" . $awc; // Populate the affiliate click
}
$c = curl_init();
curl_setopt($c, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
curl_setopt($c, CURLOPT_URL, $url);
curl_exec($c);
curl_close($c);
?>

Richard Gosler

This is a strange one now and driving me crackers. If I add the tracking code into the tracking code field in the hidden menu item, nothing renders on the confirmation page.

Moreover, If i hard code the tracking snippet into the template it still does not appear. Go figure ?

Any ideas on this.

Olivier Buisard Staff

Hi Richard,

do you have an override of the confirmation page and if so, can you check it is up-to-date with the core?

Actually, on my way to check it out.

Olivier.

Olivier Buisard Staff

Richard,

I could see the code in the view source of the page. 

I also realized that you are on a hot line with Adam, so I will leave you 2 to it :-)

Olivier.