How To Integrate Lyoness Conversion Pixel With WooCommerce

Table Of Contents

Share Article

I have just been contacted by a client to make an implementation of the Lyoness with the Woocommerce to track the conversions that are coming from Lyoness. In this article I will present what you need to do to integrate your code with Lyoness and have the pixel on the thank you page of WooCommerce so they can have the commissions.

The code will need a couple of changes so you can make it specific for you ID and VAT rate. The values without VAT should be sent to Lyoness.

Below are the steps to have the WooCommerce itegrated with  Lyoness tracking pixel:

1. Create the first page with the cookie

In the home directory of your site you just create a redireact.php or  any name with the below details:


// Default landing page


$defaultUrl = "";

// The domain under which this script is installed


$domain = "";

if (!empty($_GET["tduid"]))


$cookieDomain = "." . $domain;

setcookie("TRADEDOUBLER", $_GET["tduid"],

(time() + 3600 * 24 * 365), "/", $cookieDomain);

// If you do not use the built-in session functionality in PHP, modify

// the following expression to work with your session handling routines.




if (empty($_GET["url"]))

$url = $defaultUrl;


$url = urldecode(substr(strstr($_SERVER["QUERY_STRING"], "url"), 4));

header("Location: " . $url);


In the above code you just need to replace the value with your domain name that needs to be added to Lyoness.

Then you will have that would be used to activate the cookie for the visitors coming from Lyoness.

2. Implement the tracking pixel on the thankyou page.

The below code can be placed into a php file, the values modified with your own ( will explain ) and the php file placed into a folder ziped and loaded as a plugin:

WooCommerce Lyoness
Plugin URI: 
Description: WooCommerce Lyoness
Author: WP Doze
Author URI:
Version: 1.0.0

	Copyright: © 2016 wpdoze (email : [email protected])
	License: GNU General Public License v3.0
	License URI:

 * Check if WooCommerce is active

// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;

// Check if WooCommerce is active and bail if it's not
if ( ! WoocommerceLyoness::is_woocommerce_active() )

 * The WoocommerceCustomCheckoutCNPField global object
 * @name $woocommerce_custom_checkout_CNP_field
 * @global WoocommerceCustomCheckoutCNPField $GLOBALS['woocommerce_custom_checkout_CNP_field']
$GLOBALS['woocommerce_custom_checkout_CNP_field'] = new WoocommerceLyoness();

class WoocommerceLyoness{

	public function __construct() {
		// Installation
		if ( is_admin() && ! defined( 'DOING_AJAX' ) ) $this->install();

		add_action( 'woocommerce_init', array( $this, 'init' ) );
	public function init() {

		add_filter( 'woocommerce_thankyou' , array( $this,'LyonessTrackingPixel' ));

	public function LyonessTrackingPixel($order_id) {
			// Lets grab the order
			$order = new WC_Order( $order_id );
			 * Put your tracking code here
			 * You can get the order total etc e.g. $order->get_order_total();
			 echo $order->get_total();
			$organization = "xxxx";
			// Your checksum code; provided by Lyoness
			$checksumCode = "xxxx";
			// Value of the sale; sale specific value has to
			// be assigned dynamically out of the shop database
			$ordervtva = $order->get_total();
			$discountam = $order->get_cart_discount();
			$orderValue = number_format($ordervtva/124*100,2, '.', '');
			// Currency of the sale.
			// For example "USD" for US $, or "EUR" for Euro
			$currency = "RON";
			// Event ID; provided by Lyoness
			$event = "xxxx";
			// Event type:
			// in most cases $isSale should be left as "true" unless
			// you arranged a lead commission with Lyoness
			// true = Sale
			// false = Lead
			$isSale = true;

			// Encrypted connection on this page:
			// true = Yes (https)
			// false = No (http)
			$isSecure = true;
			// Here you must specify a unique identifier for the transaction.
			// You should assign your internal shop order number dynamically
			// out of your shop database
			//$discount_value=number_format($_SESSION['val_comision']/$orderValue*100,2, '.', '');
			$orderNumber = $order_id;
			// If you do not use the built-in session functionality in PHP, modify
			// the following expressions to work with your session handling routines.
			$tduid = "";
			if (!empty($_SESSION["TRADEDOUBLER"]))
			// OPTIONAL: You may transmit a list of items ordered in the reportInfo
			// parameter. See the chapter reportInfo for details.
			$reportInfo = ""; $reportInfo = urlencode($reportInfo);
			/***** IMPORTANT: *****/
			/***** In most cases, you should not edit anything below this line. *****/
			if (!empty($_COOKIE["TRADEDOUBLER"]))
			$tduid = $_COOKIE["TRADEDOUBLER"];
			if ($isSale)
			$domain = "";
			$checkNumberName = "orderNumber";
			$domain = "";
			$checkNumberName = "leadNumber";
			$orderValue = "1";
			$checksum = "v04" . md5($checksumCode . $orderNumber . $orderValue);
			if ($isSecure) $scheme = "https";
			else $scheme = "http";

			$trackBackUrl = $scheme . "://" . $domain . "/report"
			. "?organization=" . $organization
			. "&event=" . $event
			. "&" . $checkNumberName . "=" . $orderNumber
			. "&checksum=" . $checksum
			. "&tduid=" . $tduid
			. "&reportInfo=" . $reportInfo;
			if ($isSale)
			.= "&orderValue=" .$orderValue
			.= "¤cy=" .$currency;
			echo "\"\"";




	public static function is_woocommerce_active() {

		$active_plugins = (array) get_option( 'active_plugins', array() );

		if ( is_multisite() )
			$active_plugins = array_merge( $active_plugins, get_site_option( 'active_sitewide_plugins', array() ) );

		return in_array( 'woocommerce/woocommerce.php', $active_plugins ) || array_key_exists( 'woocommerce/woocommerce.php', $active_plugins );

	/** Lifecycle methods ******************************************************/

	 * Run every time.  Used since the activation hook is not executed when updating a plugin
	private function install() {



You need to add values for:

$organization = “xxxx”;  – Your checksum code; provided by Lyoness

$checksumCode = “xxxx”;  – will be provided by them

$currency = “RON”; — currency of the store if EUR you replace RON with EUR

The VAT value you need to modify the value with the rate in your country if the total order has vat you beed to modify  $orderValue = number_format($ordervtva/124*100,2, ‘.’, ”); In my country is 24% and in case in your is 15% you modify:  $orderValue = number_format($ordervtva/115*100,2, ‘.’, ”);

After you add the values into a php in a folder you zip it and load it at any plugin.

This is actually a plugin and if Woocomerce is updated it doesn’t affect it ( only if Woccomerce update the functions). Is working currently with the 2.6 version.

Below is the zip file for download. Be aware that you need to modify the above values first.

Download zip

Become a CloudPanel Expert

This course will teach you everything you need to know about web server management, from installation to backup and security.
Leave a Reply

Your email address will not be published. Required fields are marked *

  1. Great article, even though I was looking how to integrate Lyoness with Shopify 🙂

    It looks like that you cannot integrate Lyoness with Shopify without creating an app.

    Well anyways, your guide will come handy for my next client, so thank you!

$2000 Giveaway

Giveaway with 100 FREE coupons to an course that will help you setup CloudPanel and host your own WordPress.
Learn More