Integrating Convert Experiences with Shopify

Important

Step 1: Find your Convert Experiences Account-Project ids. 

In Convert Experiences, retrieve the project ID number from the place highlighted in the image below. 

Configuration - + Demo - Convert (1).png

Step 2: Add the Convert Experiences Script to your Shopify Theme

To integrate the two platforms, please go to Sales Channels > Online Store > Themes > More Actions > Edit Code

mceclip3.png

Select the theme.liquid file and paste the tracking code just before the first "{% if %}" section, as shown in the screenshot below:

mceclip4.png

In the area indicated above, paste the code shown below. Make sure you replace the XXXXXXX  with your own account id and the YYYYYY  number with your own project id that was mentioned earlier in this article.

<!-- begin Convert Experiences code-->
<script type="text/javascript">
var _conv_page_type = "{{ request.page_type }}";
var _conv_category_id = "{{ collection.id }}";
var _conv_category_name = "{{ collection.title }}";
var _conv_product_sku = "{{ product.selected_variant.sku }}";
var _conv_product_name = "{{ product.title }}";
var _conv_product_price = "{{ product.price_min | money_without_currency }}";
var _conv_customer_id = "{{ customer.id }}";
var _conv_custom_v1 = "{{ product.tags.first }}";
var _conv_custom_v2 = "{{ collection.current_type }}";
var _conv_custom_v3 = "{{ cart.item_count }}";
var _conv_custom_v4 = "{{ cart.total_price | money_without_currency }}";
</script>
<script type="text/javascript" src="//cdn-4.convertexperiments.com/v1/js/XXXXXXXX-YYYYYYYYY.js"></script>
<!-- end Convert Experiences code -->

Don't forget to save your changes in Shopify.

Step 3: Add Convert Tracking Code on Checkout Pages on Shopify Plus 

If you use Shopify Plus, then you also have the possibility to add the Convert Experiences script in checkout pages (pages after /cart but before thank_you/purchase_confirmation). This is not possible for non Shopify Plus subscriptions as Shopify does not allow third party scripts to be running on checkout pages.

Edit the checkout.liquid file and place your Convert Tracking Code to appear on /checkout/ pages. 

Just go to your Project Configuration to get your Convert Tracking Code ("basic snippet") and paste it into the template as shown below.

mceclip1.png

mceclip0.png

Step 4: Add the checkout page domain to your Project's Active Websites

This only applies to non-Shopify Plus users.

On Shopify, the checkout pages are either presented under a central Shopify subdomain (checkout.shopify.com) or your own domain, depending on the type of Shopify account you have. In either situation, you need to add that domain to your Project's Configuration:

mceclip2.png

Step 5: Forward tracking cookies to the checkout domain

This only applies to non-Shopify Plus users.

If you are not using your own domain or if you are using a totally different domain than your main domain for the checkout pages, you will need to manually forward the tracking cookies so that experiments fired on the shop pages can be connected later on to a conversion. To do that, on the cart page where the visitor redirects from your main domain, you need to read the convert tracking cookies and forward them to the checkout domain as explained below.  

Go to Online Store > Themes > Current Theme > Actions > Edit Code  as explained in step 2). Go to "Sections" and select the "cart-template.liquid". Then, add the following JavaScript, just before the <form> tag:

mceclip5.png

<script type="text/javascript">
function _conv_copy_cookies(form) {
try {
var _conv_v = encodeURIComponent(convert.getCookie("_conv_v"));
var _conv_s = encodeURIComponent(convert.getCookie("_conv_s"));
form.action = '/cart?_conv_v=' + _conv_v + '&_conv_s=' + _conv_s;
} catch (e) {}
return true;
}
</script>

Next, add the following inside the <form> tag:

onsubmit="return _conv_copy_cookies(this)"

After this, you should be done. Now, the Convert Experiences cookies should be forwarded to the checkout URL as two GET variables: _conv_v and _conv_s;

Note: If you use a subdomain of your main domain for checkout, then you probably do not have to complete this step. Cookies will be saved under the root domain, making them available on the shop and checkout pages.

Step 6: Setup your Shopify Customer Events tracking

  1. Create two Code (JavaScript) triggered goals. Name one Purchase Shopify Customer Event, and another one Added to the Cart Shopify Customer Event. Have their Ids handy to insert them on the script you will add to the Shopify Customer Events section.

  2. On your Shopify Admin interface go to Settings > Customer Events. Create a Custom one. Name it Convert Tracking.

    Chimpuppystore · Customers · Shopify.png
    Chimpuppystore · Customer events · Shopify.png

    Insert the code below and edit it, save it, and connect it.

    Chimpuppystore · Convert Revenue Tracking · Shopify.png

Shopify Customer Event Code

Add the following code to your Shopify Admin > Settings > Customer Events > New Pixel section. Make sure you replace the goal ids with the ones you just created. If you have the legacy tracking code (then none Beta one), please find the code here.

See the Pen Convert Shopify Customer Event Code for Legacy Tracking Code by Convert.com (@gcrewe) on CodePen.

Global Project JS code

Add the following code to your Convert App > Your Project > Configuration > Project Global JS section. If you have the legacy tracking code (then none Beta one), please find the code here.

See the Pen Manual Shopify Integration - Global Project JS V2 by Convert.com (@gcrewe) on CodePen.

Step 7: Verify your Shopify Setup

You should verify your installation using the following guide: Shopify Setup Verification Guide

GA4 Event import for Shopify Sites

Although it might seem logical to import your GA4 events to track purchases on your Shopify store, this is not possible. This is because the Convert tracking code needs to be installed on the Order Status page. However, this is not possible due to the new Shopify Checkout Extensibility. You will have to set up Customer events, such as in step 6 to be able to track revenue on Shopify using this installation setup.

Need assistance? Start a conversation with our Support Team.
CONVERT MORE

Reliably Convert More Site Visitors, Even If Everything Else is Changing in Your Business.

START 15-DAY FREE TRIAL
✓ No Credit Card  ✓ Easy Set-Up  ✓ Access All Features

Comments