This article will guide you to implement revenue tracking goals to your experiment in Shopify based website

With Freshmarketer, you can get the monetary value of every purchase or events on your site for each variation of your experiment. Freshmarketer provides you with a two-line snippet to implement into your site and track the revenue goal. 


The following are the metrics that Freshmarketer provides you when revenue is tracked from your site:

  • Revenue Per Visitor (RPV) - RPV calculates the amount of money earned each time a visitor visits your website.
  • Total Revenue - Total revenue provides the cumulative amount earned for each variation involved in an experiment.

First thing's First: 

Install Freshmarketer JS snippet on to your shopify site via GTM, To integrate Freshmarketer via GTM please follow the below detailed guide

Implement Freshmarketer Revenue Tracking Code

To track revenue of a purchase or an event, you will have to implement a snippet to your webpage event that is to be tracked.

Why need revenue tracking goal?

  • If you have an eCommerce website, then add the tracking code to the thank you page or purchase confirmation page. This helps you to rule out invalid purchases.
  • If your need is to track the revenue for every upgrade, then avoid triggering the revenue goal at the click of the button. Sometimes, user might click the button several times for several reasons.
  • Assume your revenue is subjected to no. of subscriptions your site receives, then you would have to track your subscriptions as not only a matter of conversion but also in terms of revenue.
  • Consider you run A/B testing experiment for your pricing page, variation A has pricing plans for trial users and Pro users with a pricing of $15. Variation B has a pricing plans of one at $35 and $45. Now, variation A might get more conversions than variation B. But, the real profit of the organization is achieved in variation B. Tracking revenue is essential in this case.
  • Navigate to the Goals section in your experiment. After editing the goal name, click on the drop-down menu. Select Track Revenue from the menu.

Freshmarketer’s snippet for revenue tracking goals:

window.FMApi = window.FMApi || [];
window.FMApi.push('zg_trackEvent', ' ', {'revenue': value});

Above snippet will change based on the event name you are giving in the experiment

In this guide, we have given "purchase" as event name, hence the empty single quote will be replace by event name "purchase'


window.FMApi = window.FMApi || [];
window.FMApi.push('zg_trackEvent', 'purchase', {'revenue': value});


Parameters of Freshmarketer revenue tracking code


  • Event name -Freshmarketer allows you to enter a value for Event. Example: If you want to track the revenue for every purchases. Then, set the value as “Purchase” in the event name textbox.
  • Value - This parameter(variable) denotes the cumulative monetary value of your purchases or events that you have triggered. The value can be either int or float data type.This "value" needs to given from your end to parse revenue.

Please don’t alter any other part of the revenue tracking snippet.


Creating Revenue Tracking Goal

To track the purchases that happen in shopify site you should create a Revenue tracking goal. 

Follow the below steps to add revenue tracking goal to your experiment.

STEP 1: Add revenue goal

Navigate to the Goals section in your experiment. After editing the goal name, click on the drop-down menu.

Select Track Revenue from the menu.

Select "Track Revenue"

Select "Track Revenue"

STEP 2: Implement Freshmarketer's revenue tracking snippet

A snippet appears below when the event name is entered in the textbox. Add the snippet to the event where the revenue has to be calculated.

Before Adding Snippet

After Adding the snippet

NOTE: Revenue tracking can be done for both A/B and split URL testing. Once the data is collected, the report Sample can be viewed as below.

STEP 3: Paste the snippet in Shopify Admin portal:

  • Paste the snippet that gets generated while creating a revenue tracking goal in Shopify admin -> Checkout tab -> Additional scripts as shown below .

Sample code snippet:

var purchase = {{ checkout.total_price }}

window.FMApi = window.FMApi || [];

window.FMApi.push('zg_trackEvent', 'purchase', {'revenue': purchase});

This way you can track all the purchases that happened in your shopify website.

Sample Revenue Metrics