How to integrate third party tracking system

  • Posts: 5
  • Thank you received: 0
14 years 1 month ago #10244

We are integrating our affiliate program with Shareasale. They gave us a pixel code that we need to place on our shopping cart. Below is the code:

<img src="https://shareasale.com/sale.cfm?amount=AMOUNTOFSALE&tracking=TRACKINGNUMBER&transtype=TYPEOFTRANSACTION&merchantID=31220" width="1" height="1">

We need to populate it with dynamic variable for:
    AMOUNTOFSALE
    TRACKINGNUMBER
    TYPEOFTRANSACTION

Can you help us identify the variable codes?

Please Log in or Create an account to join the conversation.

  • Posts: 83674
  • Thank you received: 13545
  • MODERATOR
14 years 1 month ago #10250

What is the tracking number and the type of transaction ? The amount of the order is in the variable $this->cart->full_total->prices[0]->price_value_with_tax in the checkout views...but there is no tracking number or type of transaction... Is that something that sharesale gives you ?

Please Log in or Create an account to join the conversation.

  • Posts: 5
  • Thank you received: 0
14 years 1 month ago #10253

the tracking number is the order number or unique identifier from that order. Each order usually have an orderid assigned by the shopping cart.

i saw that the transaction type is assigned by Shareasale so no need to get the variable for that. I just need the one for the orderid or tracking number.

also, where do i place this code? supposed to be on the thank you page or order confirmation page. how do i find it?

Please Log in or Create an account to join the conversation.

  • Posts: 83674
  • Thank you received: 13545
  • MODERATOR
14 years 1 month ago #10272

So, you need to go in the menu Display->Views and edit the file end of the view checkout. There, add the code below at the end :

$app =& JFactory::getApplication();
$order_id = $app->getUserState(HIKASHOP_COMPONENT.'.order_id');
$orderClass = hikashop::get('class.order');
$order = $orderClass->get($order_id);
echo '<img src="https://shareasale.com/sale.cfm?amount='.$order->order_full_price.'&tracking='.$order_id.'&transtype=TYPEOFTRANSACTION&merchantID=31220" width="1" height="1">';

Last edit: 14 years 1 month ago by nicolas.

Please Log in or Create an account to join the conversation.

  • Posts: 5
  • Thank you received: 0
14 years 1 month ago #10446

I placed the code on checkout / end.php

but it did not track when we made the test purchase. any ideas?

Please Log in or Create an account to join the conversation.

  • Posts: 83674
  • Thank you received: 13545
  • MODERATOR
14 years 1 month ago #10448

Did you look at the HTML code generated ? Maybe there is a problem...

Please Log in or Create an account to join the conversation.

  • Posts: 73
  • Thank you received: 0
14 years 1 month ago #11143

Hi Nicolas,

I am having the same/similar situation. Basically. I need to get the orderID and subtotal to the thank-you page. subtotal being total before tax of course.

-Bill

Please Log in or Create an account to join the conversation.

  • Posts: 83674
  • Thank you received: 13545
  • MODERATOR
14 years 1 month ago #11144

The sub total cannot be retrieved easily. You need to calculate it from the price without tax of all the products in the order, so you would first have to load their info from the database...

Please Log in or Create an account to join the conversation.

  • Posts: 73
  • Thank you received: 0
14 years 1 month ago #11586

Ok,

I got my code now. Performance-based.com wants this code on my thank you page.

<!--ROIA conversion #259--><img src="https://net.performance-based.com/l/259?id=partner_id;amount=TOTAL_WITHOUT_VAT" alt="" width="1" height="1" border="0" style="width:1px;height:1px;border:0" /><!--/ROIA conversion #259-->

I already added the partner_id and TOTAL_WITOUT_VAT variables but I'm guessing before I try it that is not going to work. I think my redirect URL I add to authorize.net for redirect back to the site after the sale should land on a HikaShop shopping cart script and include the needed values from the partner_id and TOTAL_WITHOUT_VAT. Shouldn't it? This way that page would have all the variables to fill in the conversion tracking pixel.

Thanks,
Bill

Please Log in or Create an account to join the conversation.

  • Posts: 83674
  • Thank you received: 13545
  • MODERATOR
14 years 1 month ago #11597

Instead of adding an image to the return of authorize.net, the best way would be to create a hikashop plugin ( www.hikashop.com/en/support/documentatio...r-documentation.html ) and define such code:

function onAfterOrderUpdate(&$order,&$send_email){
$config=&hikashop::config();
$confirmed = $config->get('order_confirmed_status');
//if order status is not updated skip
if(!isset($order->order_status)) return true;
$class = hikashop::get('class.order');
$dbOrder = $class->get($order->order_id);
if(empty($allProducts)){
return true;
}

if($order->order_status!=$confirmed){
//if status is not confirmed just skip
return true;
}
$vat = 0;
foreach($allProducts as $oneProduct){
$vat+=$oneProduct->order_product_quantity*$oneProduct->order_product_tax
}
$request = curl_init(' net.performance-based.com/l/259?id=XXX;amount= '.($dbOrder->order_full_price-($vat+$dbOrder->order_shipping_price+$dbOrder->order_discount_price)));
curl_setopt($request, CURLOPT_HEADER, 0);
curl_setopt($request, CURLOPT_RETURNTRANSFER, 1);
$post_response = curl_exec($request);
curl_close ($request);
}


That way, it will even work when you change manually the status from the back end. That will also have the advantage to work with any payment method and will probably be useful to other users wanting to use performance-based.com

Please Log in or Create an account to join the conversation.

  • Posts: 73
  • Thank you received: 0
14 years 1 month ago #11638

Thank you for your help and patience. This is new but I'm learning. From http://docs.joomla.org/Creating_a_Plugin_for_Joomla_1.5 I created this xml file:

<?xml version="1.0" encoding="iso-8859-1"?>
<install version="1.5" type="plugin" group="hikashop" method="upgrade" >
   <name>Notify Performance-based.com of sale status change</name>
   <author>Nicolas</author>
   <creationDate>21 March 2011</creationDate>
   <copyright>(C) 2011 HikaShop. All rights reserved.</copyright> 
   <license>GNU/GPL</license>
   <authorEmail>nicolas[works for]hikashop.com</authorEmail>
   <authorUrl>www.HikaShop.com</authorUrl>
   <version>0.1</version>
   <description>Allows notification of sale status change to performanced-based.com</description>
   <files>
       <filename plugin="hikashop.notify_performance-based">hikashop.notify_performance-based.php</filename>
   </files>
   
</install>

and from your post above combined with the example form joomla.org I created this:
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
 
// Import library dependencies
jimport('joomla.plugin.plugin');
 
class plg<hikashop><notify_performance-based> extends JPlugin
{
/**
 * Constructor
 *
 * For php4 compatability we must not use the __constructor as a constructor for
 * plugins because func_get_args ( void ) returns a copy of all passed arguments
 * NOT references.  This causes problems with cross-referencing necessary for the
 * observer design pattern.
 */
 function plg<PluginGroup><notify_performance-based>()
 {
    parent::__construct();
 
    // load plugin parameters
    $this->_plugin = JPluginHelper::getPlugin( '<hikashop>', '<notify_perfomance-based>' );
    $this->_params = new JParameter( $this->_plugin->params );
 }



function onAfterOrderUpdate(&$order,&$send_email){
$config=&hikashop::config();
$confirmed = $config->get('order_confirmed_status');
//if order status is not updated skip
if(!isset($order->order_status)) return true;
$class = hikashop::get('class.order');
$dbOrder = $class->get($order->order_id);
if(empty($allProducts)){
return true;
}

if($order->order_status!=$confirmed){
//if status is not confirmed just skip
return true;
}
$vat = 0;
foreach($allProducts as $oneProduct){
$vat+=$oneProduct->order_product_quantity*$oneProduct->order_product_tax
}
$request = curl_init('net.performance-based.com/l/259?id=XXX;amount='.($dbOrder->order_full_price-($vat+

$dbOrder->order_shipping_price+$dbOrder->order_discount_price)));
curl_setopt($request, CURLOPT_HEADER, 0);
curl_setopt($request, CURLOPT_RETURNTRANSFER, 1);
$post_response = curl_exec($request);
curl_close ($request);
}
I have both in the attached zip file and am ready to install I think. Do you want to give it a look before hand?

-Bill

File Attachment:

File Name: hms_hikash...gins.zip
File Size:2 KB

Attachments:
Last edit: 14 years 1 month ago by bthayer.

Please Log in or Create an account to join the conversation.

  • Posts: 83674
  • Thank you received: 13545
  • MODERATOR
14 years 1 month ago #11644

So here are the problems:

1. Your files are called notify_performance-based.php.txt and notify_performance-based.xml.txt so you should remove the .txt at the end
2. Avoid using - and _ in names
3. The < > in the class name should not be there. So the class name should be plgHikashopNotify_performance_based
4. You're missing a closing bracket at the end of your code. You should indent your code in order to see that easily.

Attached is a corrected version (not tested though).

File Attachment:

File Name: hms_hikash...0322.zip
File Size:1 KB

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 73
  • Thank you received: 0
14 years 1 month ago #11709

Thank you much.

in the line:

$request = curl_init('net.performance-based.com/l/259?id=XXX;
should XXX be
$dbOrder->order_id

?

-Bill

Please Log in or Create an account to join the conversation.

  • Posts: 83674
  • Thank you received: 13545
  • MODERATOR
14 years 1 month ago #11710

From what you said earlier, the id parameter should be a partner id:

I got my code now. Performance-based.com wants this code on my thank you page.


Code:
<!--ROIA conversion #259--><img src=" net.performance-based.com/l/259?id=partn...nt=TOTAL_WITHOUT_VAT " alt="" width="1" height="1" border="0" style="width:1px;height:1px;border:0" /><!--/ROIA conversion #259-->


I already added the partner_id

Please Log in or Create an account to join the conversation.

  • Posts: 73
  • Thank you received: 0
14 years 1 month ago #11734

I had it wrong at first. It's the order ID in the XXX.

I have bigger problems now. The plugin is installed and enabled. During testing we (my affiliate manager and I) decided that I better simplify the checkout so I set the registration to "no registration". I had the long "old school flow" and step 6 ended up being an empty page. That pretty much ended our conference call until I can get this straight and shorten the flow.

Other issues found while troubleshooting:
1) I did upgrade but now I notice 2 geolocation plugins listed that I never noticed before. I had it disabled during the upgrade so maybe that had something to do with it? The demo site has 2 affiliate plugins ans 2 category plugins.
2) I noticed that if you take the login step out of the checkout flow then you loose the address layout as well. The work around is to leave login_ in the flow but set Login option to no. I verified this on the demo site.
3) The terms of service link does not render the terms of service page (it's broken). I did an override - PLEASE_ACCEPT_TERMS_BEFORE_FINSIHING_ORDER="Please accept the <a href=" www.heatmisersaves.com/terms-of-service " target="_blank">terms and conditions</a> before proceeding"
4) The configuration display tab has a footer section not mentioned in the Help file (unless I'm blind) and I'm curious to know what goes in the Affiliate box?
5) The demo checkout has nice bold titles and borders around the layouts that I don't have.

My biggest issue is that instead of going to authorise.net page I get a big white empty browser. This one has me stumped I hope it's a simple fix.

-Bill

Please Log in or Create an account to join the conversation.

  • Posts: 83674
  • Thank you received: 13545
  • MODERATOR
14 years 1 month ago #11747

1. Yes the geolocation plugin has been rewritten completely in december. So, if you had an old version, you should have the old one unpublished (the one in the group hikashop) and the system one published if you want to use geolocation (you also need to configure the plugin...).

2. Yes. That's not a bug. It's written in the documentation. You can't have the address without the login.

3. It's a problem of quotes. You need to use simple quotes in your HTML.

4. That enables you to add your hikashop.com affiliate id to the footer. That way you can earn money from sales on our website which were brought from your website.

5. That's because hikashop uses your template's styles. On our demo website, there are no styles for the fieldsets so it's the default display. You need to change your template CSS for fieldset styles.

6. A blank screen doesn't help us in knowing from where the problem comes. Could you activate the display_errors option of your php and try again:
www.hikashop.com/en/support/documentatio...-install.html#errors

Please Log in or Create an account to join the conversation.

  • Posts: 73
  • Thank you received: 0
14 years 1 month ago #11765

Thank you.

I could not find the php.ini and your help file says to restart the server. I put in a ticket with iPage. Hopefully it will get completed in the next hour.

Regards,
Bill

Update: The display_error variable was already set to On in the php.ini file. I'm trying to track down the error log files now.

-Bill
www.HeatMiserSaves.com

Update2: This error seems to be appearing at the top of the frontend and backend but I don't know that it has anything to do with the shopping cart, "
Notice: Undefined index: QUERY_STRING in /hermes/bosweb/web070/b706/ipg.heatmisersavescom/libraries/joomla/environment/uri.php on line 161"

Last edit: 14 years 1 month ago by bthayer.

Please Log in or Create an account to join the conversation.

  • Posts: 73
  • Thank you received: 0
14 years 1 month ago #11807

I emailed you the latest zip file and error codes.

I think we have an unrelated error or possibly bug but I'm not sure so I am writing it up here. This error occurs when I logged out of the back end.

Fatal error: Class 'hikashop' not found in /hermes/bosweb/web070/b706/ipg.heatmisersavescom/plugins/user/hikashop.php on line 80.

-Bill

Please Log in or Create an account to join the conversation.

  • Posts: 83674
  • Thank you received: 13545
  • MODERATOR
14 years 1 month ago #11818

You need to change the lines:
function plgHikashopNotify_performance_based(){
parent::__construct();

to:
function plgHikashopNotify_performance_based(& $subject, $config = array()){
parent::__construct($subject, $config);

in the plugin's code. That's probably why you're getting the blank page.

For the bug when logging out, that's a problem in hikashop. You need to add the code:
if(!include_once(rtrim(JPATH_ADMINISTRATOR,DS).DS.'components'.DS.'com_hikashop'.DS.'helpers'.DS.'helper.php')) return true;

before the lines:
$userClass = hikashop::get('class.user');
$user_id = $userClass->getID($user,'cms');

in the file plugins/user/hikashop.php
We fixed that problem and published a new build of hikashop on our end.

Please Log in or Create an account to join the conversation.

  • Posts: 73
  • Thank you received: 0
14 years 1 month ago #11839

If it's not one thing it's another eh?

I replaced the lines as you described for my plugin then ran a test case. The transaction got to the Authorize.net page and I ran a test that did go through. However, I got this message instead of getting redirected back to the orders page.

From secure.authorize.net/gateway/transact.dll

An error occurred while trying to report this transaction to the merchant. An e-mail has been sent to the merchant informing them of the error. The following is the result of the attempt to charge your credit card.

This transaction has been approved.

It is advisable for you to contact the merchant to verify that you will receive the product or service.


I'll let you know how the logout fix goes later.

Thanks for your help and patience.

-Bill

Update1: I am testing the checkout using the bank transfer plugin like in the documentation example. I get this error on the end page.

Notice: Trying to get property of non-object in /hermes/bosweb/web070/b706/ipg.heatmisersavescom/plugins/hikashop/notify_performance_based.php on line 15


When I change the status of this order to "confirmed" I get this error in the lightbox (I hope I'm using the term correctly).

JUser::_load: Unable to load user with id: 112

Last edit: 14 years 1 month ago by bthayer.

Please Log in or Create an account to join the conversation.

Time to create page: 0.101 seconds
Powered by Kunena Forum