Menu Close

Get Support From ShopWired Close

All Systems Are Operational

Subscribe To Updates
Prefer To Live Chat? Chat directly with ShopWired support Available 9.00am to 7.00pm Monday to Friday
11.00am to 5.00pm Saturday
Quickest response time

Send A Message
Response within 24 hours

Menu Close

Menu

Conversion scripts and dynamic variables

Warning!

If implemented incorrectly the following guidance can negatively affect the functionality of your website’s checkout. Upon completing the steps found in this guide you should thoroughly test your checkout to ensure it is working correctly. If you find that your checkout process is no longer working properly then you should delete the file you created and try again.

Any conversion tracking code that you enter in the conversion code field of the visitor tracking page in your ShopWired account will be loaded onto the ‘Checkout complete’ page of your website (this is the page customers are taken to once they complete a purchase).

This code, however, cannot load/send dynamic variables for conversion tracking. If you need to use dynamic variables within the script, such as sending the total value of the order or details of the products purchased, it will need to be installed directly into your theme files.

In order for this process to work your ShopWired account must be using the platform checkout feature.

• Installing the code in your theme
• Example implementation


Installing the code in your theme

To install the code on your live theme select Themes > Installed Themes from the menu, and then select Page Editor on your live theme:

In the left menu that then appears select the tick box beside ‘advanced mode disabled’ to enable advanced mode:

Open the views folder and select Create new:

In the box that appears enter the name as platform_checkout.twig and select create:

Then copy and paste the following code into the empty file page:

{% extends 'shopwired/platform-checkout/master.twig' %}
{% block scripts %}
	{{ parent() }}
	{% if global.current_path == '/checkout/complete' %}
		...
	{% endif %}
{% endblock %}

Replace the ... in the above code with the conversion script supplied to you by your provider. You’ll then need to identify the places within that script that require dynamic code. For help and clarification with this you should consult your provider’s help guides or support team. Once you have identified the places that require dynamic code, replace them with the corresponding twig variables for an order.


Twig variables

Common variables are listed here, and you must use them exactly as they are written, including the {{ }} symbols:

{{ order.reference }} will output the reference number of the order

{{ order.total }} will output the total value of the order

{{ order.original_sub_total }} will output the total value of products in the order, before any discounts are applied

{{ order.sub_total }} will output the total value of products in the order, after any discounts are applied

{{ order.original_shipping_total }} will output the total value of shipping on the order, before any discounts are applied

{{ order.shipping_total }} will output the total value of shipping on the order, after any discounts are applied

{{ order.discount_total }} will output the total value of discounts on the order

order.discounts will output details about the discounts applied to the order, this is an array and will need more detailed coding

order.products will output details about the products in the order, this is an array and will need more detailed coding

For the full set of available variables see the Order Object help guide.


Once you have finished inputting your code into the file select save changes.

Then you should place a test order on your website, coordinated with your conversion tracking provider, to ensure that the code is working correctly.


Example implementation

The code shown below is for illustrative purposes only. Dynamic code is highlighted in red.

{% extends 'shopwired/platform-checkout/master.twig' %}
{% block scripts %}
{{ parent() }}
{% if global.current_path == '/checkout/complete' %}
	<script type="text/javascript">
	var AWIN = {};
	AWIN.Tracking = {};
	AWIN.Tracking.Sale = {};
	/*** Set your transaction parameters ***/
	AWIN.Tracking.Sale.amount = "{{ order.sub_total }}";
	AWIN.Tracking.Sale.orderRef = "{{ order.reference }}";
	AWIN.Tracking.Sale.parts = "DEFAULT:{{ order.sub_total }}";
	AWIN.Tracking.Sale.voucher = 
		"{% for discount in order.discounts %}{{ discount.name }}{% endfor %}";
	AWIN.Tracking.Sale.currency = "GBP";
	AWIN.Tracking.Sale.test = "0";
	AWIN.Tracking.Sale.channel = "aw";
	</script>
{% endif %}
{% endblock %}