Customers may receive an abandoned cart email after making a purchase if the Fresh Relevance script doesn't load on the purchase complete page or if the customer closes the page too quickly.
The script is designed to track purchases and prevent emails from being sent to customers who have completed a purchase.
Prevent abandoned cart emails after purchase
To register every purchase complete event and ensure customers who have made a purchase don't receive abandoned cart emails, you can include an additional tracking pixel (image) on your purchase confirmation page.
This step is optional for Fresh Relevance trial users but is strongly recommended for long-term use.
To add the additional tracking pixel:
Find the relevant image tag in the section Tracking pixel.
In the code snippet, replace the [customer's email address] with the appropriate code to merge the customer's email address using your e-commerce software.
Include the code on all of your confirmation pages.
This helps track purchases and prevent abandoned cart emails from being sent to customers who have completed a purchase.
Tracking pixel
To ensure that every purchase complete event is registered and buyers aren't sent cart abandonment emails, include the following tracking pixel on the purchase confirmation page of your ecommerce system:
Customer email
Merge the customer's email address into the placeholder "[customer's email address]" on your ecommerce system (without the brackets).
<img src="//d1f0tbk1v3e25u.cloudfront.net/pc/[your Website ID here]/?e=[customer's email address]" id="__tms_pc" height="1" width="1" />
Customer email and order reference number
Merge the customer's email address into the placeholder "[customer's email address]" on your ecommerce system (without the brackets).
Also, merge the unique order number/reference into the placeholder "[order / reference number]" on your ecommerce system (without the brackets). Note that the order ID must be unique across all sites used in the same account.
<img src="//d1f0tbk1v3e25u.cloudfront.net/pc/[your Website ID here]/?e=[customer's email address]&r=[order / reference number]" id="__tms_pc" height="1" width="1" />
Server-side request
Alternatively, this request can be made server-side on behalf of the user. A few examples are provided below.
In these examples, replace the placeholders with the appropriate variables for the customer's email address and order/reference number on your ecommerce system.
Python example:
import urllib.request
import urllib.parse
data = {}
data['e'] = 'Email Address Here'
data['r'] = 'Order/Reference Here'
url_values = urllib.parse.urlencode(data)
url = 'http://d1f0tbk1v3e25u.cloudfront.net/pc/[your Website ID here]/'
full_url = url + '?' + url_values
data = urllib.request.open(full_url)
Node.js Example:
Ensure you have the HTTPS node package installed by running npm i https.
const https = require('https')
const options = {
hostname: 'http://d1f0tbk1v3e25u.cloudfront.net/pc/[your Website ID here]/',
port: 443,
path: `?e=${email}&r=${ordernum}`,
method: 'GET'
}
const req = https.request(options, (res) => {
console.log(`statusCode: ${res.statusCode}`)
res.on('data', (d) => {
process.stdout.write(d)
})
})
req.on('error', (error) => {
console.error(error)
})
req.end()
PHP example:
$url = 'http://d1f0tbk1v3e25u.cloudfront.net/pc/[your Website ID here]/?e=' . $email . '&r=' . $ordernum;
$ch = curl_init( $url );
curl_setopt( $ch, CURLOPT_HEADER, 0);
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec( $ch );
curl_close($ch);