- Help Center
- Shopify
-
Getting Started
-
Configuration
- Targeting
- Split URL
- Product Testing
- Full Stack
- Experiment Management
- CSP Configuration
- Experiment Execution
- Reports
- Exit Popups
- GTM Integration
- Troubleshooting
- Performance Optimization
- Event-Triggered Changes
- Holdout Groups
- Split URL Pages
- URL Parameters
- DataLayer
- Menu Configurations
- Traffic Exclusion
- Experiment Scheduling
- Dynamic Element Changes
- Price Targeting
- Experience Scheduling
- Privacy
- Hash Changes
- Async Tracking
- Selective Installation
- CSS Selectors
- Vue.js Integration
- Page Content
- Multipage Split URL
- Organic Traffic
- Visual Editor
- Server-Side Testing
- Traffic Bucketing
- GDPR Warnings
- Statistical Confidence
- Browser Privacy
- Query Parameters
- Embedded Videos
- Tracking Code Execution
- Simultaneous Experiments
- Tags
- Deployments
- Disable Testing
- Locations
- Programmatic Bucketting
- Query Parameter Handling
- Convert Library
- Variation Previews
- Experiment Editing
- Opt-Out Script
- Data Reset
- Body Hiding
- Visit-Specific Variations
- Variation Styling
- Preview Issues
- Variation Editing
- Full-Site Testing
- Blinking Variations
- Cross-Domain Cookies
- Regex Support
- Conversion Tracking
- SPA Testing
- Project Setup
- Cross-Domain Tracking
- Geo-Targeting
- Analytics Tools
- Campaign Tags
- Previewing
- IDs
- Query String Targeting
- Bounce Rate Goals
- Bot Filtering
- Query String Variables
- Custom Audiences
- Redirects
- Baseline
- Tracking Code Location
- Secure Cookies
- AngularJS
- Cloudflare
- Code Installation
-
Track Goals
- Form Tracking
- Cookie Management
- iFrame Click Tracking
- Performance Optimization
- Revenue Tracking
- Interaction Goals
- Form Submissions
- Advanced Goals
- Lazy Loading
- Multi-Conversions
- URL Parameters
- Bounce Rate Goals
- DataLayer Integration
- Scroll Depth
- Social Interactions
- Page Views
- Marketo Forms
- Feature Analysis
- AJAX Forms
- Revenue Tracking via GTM
- Order Outliers
- Cumulative Revenue
- Goal Templates
- Adding Revenue Goals
- JS-Based Goals
- Goal Basics
- Google Analytics Goals
- Social Sharing
- Dynamic Goals
- Typeform Integration
-
Target Visitors
- Geolocation
- Interaction Goals
- Goal-Based Targeting
- Weather Targeting
- Cookie-Based Targeting
- Page Visits
- Audience Management
- Audience Segmentation
- Experiment Targeting
- Advanced Audience Creation
- Audience Templates
- Audience Creation
- Data Layer Integration
- Manual Activation
- JavaScript Conditions
- Device Targeting
- Language Targeting
- IP-Based Exclusion
- Visitor Management
- Page Tagging
- Cookies
-
Troubleshooting
- Google Warnings
- Visual Editor
- HTTPS Content
- Logs
- Support Options
- Bootstrap
- Cookie Blocking
- Change History
- Mobile Debugging
- AdWords
- Bot Exclusion
- Domain Issues
- Cloudflare Issues
- Monitoring
- Cloaking Penalties
- Goal Editor Issues
- Variations
- Snippet Performance
- Changes Not Saved
- Blocked Visual Editor
- Goal Testing
- Visual Editor Browsing
- Experiment Issues
- Installation Verification
- Data Leak Prevention
- Usage Limits
- Experiment Previews
- GA4 Revenue
- Chrome Debugger Logs
- SPA Errors
- Checkout JSON Error
-
Analyze Results
-
Integrations
- Google Analytics
- Cookie Consent Platforms
- Microsoft Clarity
- Plausible
- Marketo
- HubSpot
- Tealium
- Smartlook
- Klaviyo
- Salesforce CRM
- FullStory
- Snowplow Analytics
- Webflow
- GA4 Roles
- Amplitude
- Segment
- React
- BigCommerce
- WooCommerce
- Active Campaign
- Google Tag Manager
- Mixpanel
- Zapier
- Inspectlet
- Crazy Egg
- LanderApp
- Unbounce
- Instapage
- Drupal
- PrestaShop
- Magento
- Roistat
- Piano Analytics
- Heap Analytics
- Kissmetrics
- Mouseflow
- Adobe Analytics
- Clicky
-
Account Management
-
Developers
-
What's New
-
Common Questions
-
Shopify
Track SKU products or subscriptions separately in Shopify
THIS ARTICLE WILL HELP YOU:
SKU tracking
You can create a goal that would fire only when a product with a certain SKU is purchased.
For this, you would need to install the following JavaScript code in the same way that the manual revenue tracking is installed on Shopify. You could append the code along the manual revenue tracking code, making a goal for general revenue tracking and one for a specific SKU.
You would only need to change the id, to the revenue goal that you create for this on the Convert app.
<script>
total_sku_revenue = 0;
total_sku_products = 0;
function reportRevenue(revenue,product_count) {
_conv_q = window._conv_q || [];
// Replace the number for your Revenue Goal Id
_conv_q.push(["pushRevenue", revenue, product_count, "100134184"]);
console.log('SKU Specific Report:revenue='+revenue+': Product Count='+product_count);
}
Shopify.checkout.line_items.forEach(product => {
if (product.sku.includes('rose')){
total_sku_revenue = product.line_price + total_sku_revenue;
total_sku_products = 1 + total_sku_products;
}
})
if (total_sku_products > 0) {
reportRevenue(total_sku_revenue,total_sku_products)
}total_sku_revenue = 0;
total_sku_products = 0;
function reportRevenue(revenue,product_count) {
_conv_q = window._conv_q || [];
// Replace the number for your Revenue Goal Id
_conv_q.push(["pushRevenue", revenue, product_count, "100134184"]);
console.log('SKU Specific Report:revenue='+revenue+': Product Count='+product_count);
}
Shopify.checkout.line_items.forEach(product => {
if (product.sku.includes('rose')){
total_sku_revenue = product.line_price + total_sku_revenue;
total_sku_products = 1 + total_sku_products;
}
})
if (total_sku_products > 0) {
reportRevenue(total_sku_revenue,total_sku_products)
}
</script>
Subscription Tracking
To separate subscriptions from non-subscriptions you can use the following code. Make sure you add a separate revenue goal for subscriptions and non subscriptions.
<script>
document.addEventListener("DOMContentLoaded", function() {
let convertRevenueCurrency = false;
let currencyToConvertTo = 'USD';
function reportRevenue(revenue, product_count, goal_id, purchase_type, Currency) {
let _conv_q = window._conv_q || [];
// Enable next line if currency conversion is needed.
if (convertRevenueCurrency) {
revenue = Currency.convert(revenue, Shopify.checkout.currency, currencyToConvertTo);
}
_conv_q.push(["pushRevenue", revenue, product_count, goal_id]);
console.log(purchase_type + ' Report: revenue=' + revenue + ': Product Count=' + product_count);
}
const xhr = new XMLHttpRequest();
xhr.open('GET', 'https://cdn.shopify.com/s/javascripts/currencies.js');
xhr.onload = function() {
console.log('xhr status ' + xhr.status);
if (xhr.status === 200) {
eval(xhr.responseText);
let total_subs_revenue = 0;
let total_subs_products = 0;
let total_non_subs_revenue = 0;
let total_non_subs_products = 0;
Shopify.checkout.line_items.forEach(product => {
// Following line checks if it is a subscribed product by querying a specific property of the product
if (product.selling_plan_allocation && product.selling_plan_allocation.selling_plan.recurring_deliveries) {
total_subs_revenue += product.line_price - product.line_level_total_discount;
total_subs_products += 1;
} else {
total_non_subs_revenue += product.line_price - product.line_level_total_discount;
total_non_subs_products += 1;
}
});
if (total_subs_products > 0) {
// Change goal id to the one created for subscriptions
reportRevenue(total_subs_revenue, total_subs_products, '100453380', 'subscriptions', Currency);
}
if (total_non_subs_products > 0) {
// Change goal id to the one created for non-subscriptions
reportRevenue(total_non_subs_revenue, total_non_subs_products, '100453381', 'non subscription', Currency);
}
}
};
xhr.send();
});
</script>
Tracking Subscriptions within Shopify Customer Events
You can substitute your Shopify Customer Event code to separate subscriptions from non-subscriptions.