Install the conversion tracking code
Nick Hemenway avatar
Written by Nick Hemenway
Updated over a week ago

Note If you are using a supported platform, the conversion tracking code is automatically installed.

In order to earn the Shopper Identity Protection and Issue-Free Orders certifications, you’ll first need to install the conversion tracking code.

To install the conversion tracking code, add the following code to your purchase confirmation page, filling out the bracketed content with the real values.

<script 
src="https://cdn.ywxi.net/js/conversion.js"
class="trustedsite-track-conversion" //required
data-orderid="1234" //required
data-email="john_doe@domain.com" //required for automatic opt-in method only
data-firstname="John"
data-lastname="Doe"
data-country="US" //two letter codes, see eg https://www.iban.com/country-codes
data-state="CA" //two letter codes, see eg https://pe.usps.com/text/pub28/28apb.htm
data-ifodays="20" //integer denoting whole days before the email will be sent
></script>

In the example above, values that are not marked as required are optional. For the service to work properly, you'll need to provide at least the order ID.

The data-ifodays is an optional argument that can be given when including conversion.js which specifies the number of days before the order’s Issue-Free Orders email should be sent. If not set, the email will be sent after 7 days by default.

Including the optional values (other than ifodays) means that the forms for non-automatic opt-ins will have the values pre-filled in for the user, improving the user experience.

While the exact procedure may vary depending on your site's infrastructure, you can use the two examples below as a general guidance for how to customize the code:

Ruby example:

<script 
src="https://cdn.ywxi.net/js/conversion.js"
class="trustedsite-track-conversion"
data-type="purchase" data-orderid="<%= current_user.last_order_id %>"
data-email="<%= current_user.email %>"
data-firstname="<%= current_user.first_name %>"
data-lastname="<%= current_user.last_name %>"
data-country="US"
></script>

PHP Example:

<script 
src="https://cdn.ywxi.net/js/conversion.js"
class="trustedsite-track-conversion"
data-type="purchase" data-orderid="<?php current_user.last_order_id ?>"
data-email="<?php current_user.email ?>"
data-firstname="<?php current_user.first_name ?>"
data-lastname="<?php current_user.last_name ?>"
data-country="US"
></script>

After installing the code, you will need to select a customer opt-in method in order to enable Shopper Identity Protection and Issue-Free Orders. To do this:

  1. Log in to your account.

  2. If you have multiple sites in your account, click the one you want to manage.

  3. From the site overview page, click Set Up then Conversion Tracking.

  4. Copy and paste the code to your purchase confirmation page, and replace the bracketed content with real values.

  5. Select an opt-in method for Shopper Identity Protection from the dropdown menu.

Once you have the conversion tracking code installed and you have made some sales, you can begin tracking purchases from the Overview page in your TrustedSite dashboard.

Did this answer your question?