Integrating Convert Experiences with Shopify

Important:
Before you start installing the Convert Shopify integration, make sure you read the Shopify Get Started guide so you choose the right integration.


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. 

s1

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

s2

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

s3

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, which 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: 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.

    s8
    s9

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

    s10

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.

Step 4 Copy code into your 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.

Step 5 Add the tracking code to the checkout pages

This only works if you have access to your checkout liquid template. New Shopify setup does not allow this, so skip it if you do not have a checkout liquid template.

Stop here if you are using Shopify Checkout Extensibility and have completed all the previous steps. Your setup is complete.

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.

 

s4

 

s5

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

This only applies to non-Shopify Plus users and if your checkout domain is not the same as the one in the catalog pages. If you are on Shopify Plus stop here!

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:

s6

Step 7: Forward tracking cookies to the checkout domain

This only applies to non-Shopify Plus users and if your checkout domain is not the same as the one in the catalog pages. If you are on Shopify Plus stop here!

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 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:

s7

<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 8: 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.