Add Revenue Tracking to Shopify via Webhook

Shopify Webhooks

Instead of using the Google Analytics Ecommerce code or the Manual Revenue Tracking code to capture revenue on your store, you can use the Shopify Webhook method we provide below.

Shopify webhook is a feature that allows a website to notify other systems when events arise. For example, when you create a new order, it will help other systems can actively take information from CRM when data arises. In particular, webhooks can also store those data.

With webhooks, you will receive push notifications when an event occurs. You will not need to probe the API to determine whether these events have occurred or not. Webhooks allows you to provide a URL for the webhook provider to send requests to. 

This method of tracking revenue conversions is more robust than the manual revenue tracking method of creating a Revenue Goal that tracks the "Thank you" page. The reason is that is actually triggered when an order is created, rather than when a visitor visits the thank you page. 

Create a Revenue Goal in your Convert account

Go to goals and select the template Revenue Goal:

mceclip1.png

Add your Goal name and select either Manual Revenue Tracking or GA since it does not matter. Write down the Goal ID since you will use it in the next step:

mceclip0.png

Add code to your Global Project Javascript

Add this JS code to the "Global Project Javascript". Be sure to update the revenue_goal_id in the code below with your own which you created in the previous step:

See the Pen Revenue via Shopify Webhook by Convert.com (@gcrewe) on CodePen.

Configure a webhook using the Shopify admin

You can configure your webhook using the Shopify admin. From your Shopify admin, go to Settings > Notifications.

mceclip2.png

After you've created the webhook, you are presented with a secret to validate its integrity. You can also test it.

Also, be aware that it has been reported that Shopify removes webhook configurations that have not used within a certain time period. Check that the webhook already exists before requesting the Convert support team to debug your conversions. 

Access your Convert Report

You will start receiving revenue data in your report:

Compatibility with other Upsell and Subscription Shopify Plugins

This integration should be compatible with other upsell and subscription plugins that use the Shopify API to create orders within Shopify. 

It has been verified by the Convert team that this integration can track Recharge Shopify plugin orders. 

Changing the revenue goal depending on external factors

It is possible to change the triggered revenue goal, depending on other factors. A real example is differentiating normal orders from subscription orders. 

For this, you would need to create the different revenue goals as instructed above. Let's say, one called Normal Orders and another one called Subscription Orders. Then you need to gather the corresponding id for each of the orders.

Then you need to create an if the condition that replaces the goal based on the different order types. 

Somehow, you will need to determine with code what type of order is being created. This is very particular to each site. 

In the following example, a jquery instruction determines if a checkbox is checked which signals subscription orders, and then the goal is set to be a subscription goal.

 // Create a goal and change the id below
if (convert.$('.cart-sub-div--checked').length > 0) {
// Set goal id for Subscription Goal id.
var revenue_goal_id = '100000002';
}
else {
// Set goal id for Normal Order Goal id.
var revenue_goal_id = '100000001';
}
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