Microsoft Clarity for Shopify: Complete Setup and Optimization Guide
Shopify gives you sales data. Clarity shows you why some visitors buy and others leave. This guide walks through three ways to add Microsoft Clarity to your Shopify store, plus concrete strategies for using heatmaps and recordings to improve your conversion rate.
Why Shopify stores need behavior analytics
Shopify's built-in analytics tell you conversion rate, average order value, and traffic sources. But they can't show you why a customer hesitated on the product page, struggled with variant selection, or abandoned checkout on the shipping step.
Microsoft Clarity fills this gap with:
- Session recordings — Watch real shoppers navigate your store
- Heatmaps — See where people click and how far they scroll on product pages
- Frustration signals — Automatically detect rage clicks, dead clicks, and excessive scrolling
- Zero cost — Free with unlimited sessions, no matter how much traffic your store gets
Method 1: Add Clarity via theme.liquid (recommended)
This is the most reliable method and works with every Shopify theme.
- In Shopify admin, go to Online Store → Themes.
- Click Actions → Edit code on your active theme.
- Open the
theme.liquidfile (under Layout). - Find the
</head>closing tag. - Paste the Clarity tracking script just before it:
<script type="text/javascript">
(function(c,l,a,r,i,t,y){
c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};
t=l.createElement(r);t.async=1;
t.src="https://www.clarity.ms/tag/"+i;
y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);
})(window,document,"clarity","script","YOUR_PROJECT_ID");
</script>
- Click Save.
Tip: Get your project ID from the Clarity dashboard URL: clarity.ms/app/your_id/dashboard. It's also shown in the tracking code snippet under Settings → Setup.
Tracking checkout pages
Shopify's checkout is hosted on a separate subdomain (checkout.shopify.com) for most plans. The theme.liquid method only tracks your storefront pages. To track checkout:
- Shopify Plus — You have access to
checkout.liquid. Add the Clarity script there too. - Standard plans — Go to Settings → Checkout → Additional scripts and paste the Clarity tracking code. This section runs scripts on the order status/thank-you page.
Note: Standard Shopify plans have limited checkout customization. You can track the thank-you page but not individual checkout steps.
Method 2: Using a Shopify app
Several third-party apps in the Shopify App Store can install Clarity for you. Search for "Microsoft Clarity" in the App Store. These apps typically:
- Inject the tracking script automatically
- Provide a settings page within Shopify admin
- Some add additional features like custom event triggers
The downside: you're adding another app (and potential performance overhead) for something a single script can handle. For most stores, Method 1 is simpler and faster.
Method 3: Via Google Tag Manager (GTM)
If you already use GTM on your Shopify store, adding Clarity through it is straightforward:
- Make sure GTM is installed on your Shopify store (via
theme.liquidor an app). - In GTM, create a new Custom HTML tag with the Clarity script.
- Set the trigger to All Pages.
- Publish the container.
GTM gives you the most control — you can conditionally fire Clarity only on specific pages, exclude bot traffic, or delay loading for performance optimization.
Product page optimization with heatmaps
Product pages are where buying decisions happen. Here's what to look for in Clarity heatmaps:
Click distribution
Run a click heatmap on your top-selling product page. You'll typically see:
- Image gallery — High clicks. Good — shoppers are engaging with photos.
- Size/variant selectors — Look for rage clicks. If shoppers click the same variant multiple times, the selector might be unresponsive or confusing.
- Add to Cart button — Dead clicks nearby suggest the button isn't where users expect it, or they're trying to click something that looks clickable but isn't.
- Reviews section — If you use a reviews app (Judge.me, Loox), check if shoppers scroll down to read reviews. If not, consider surfacing a review summary higher on the page.
Scroll depth analysis
Shopify product pages can get long — description, reviews, related products, trust badges. Use Clarity's scroll heatmap to see what percentage of visitors reach each section. If 80% of shoppers never see your "Free Shipping" badge at the bottom, move it above the fold.
Tip: Compare scroll depth between mobile and desktop. Shopify stores often get 70%+ mobile traffic, and mobile users scroll differently. Always check both device types in Clarity.
Cart abandonment analysis
Cart abandonment is the biggest revenue leak for Shopify stores (average rate: ~70%). Clarity can show you exactly where and why shoppers drop off.
Watch cart page recordings
Filter Clarity recordings by URL containing /cart. Watch sessions where the user visited the cart but never reached checkout. Common patterns you'll spot:
- Shipping calculator confusion — Users enter their zip code, see unexpected shipping costs, and leave.
- Coupon code hunting — Users click the discount code field, leave to search for codes, and never return.
- Quantity adjustment issues — Rage clicks on tiny +/- buttons on mobile.
- Trust concerns — Users scroll up and down looking for return policy or security badges.
Use custom tags for funnel analysis
Tag sessions by funnel stage using Clarity's JavaScript API:
// In theme.liquid, detect page type
{% if template contains 'product' %}
clarity("set", "page_type", "product");
{% elsif template contains 'cart' %}
clarity("set", "page_type", "cart");
{% elsif template contains 'checkout' %}
clarity("set", "page_type", "checkout");
{% endif %}
This lets you filter sessions in Clarity by funnel stage and quickly find abandonment recordings at each step.
Shopify-specific tips
Handle dynamic content correctly
Shopify themes use AJAX for add-to-cart, quick view modals, and collection filtering. Clarity records these interactions, but heatmaps can be tricky with dynamically loaded content. If your heatmap data looks sparse on pages with heavy AJAX, check session recordings instead — they capture the full interaction including dynamic elements.
Exclude internal traffic
Your team browsing the store, testing orders, and checking product pages creates noise in Clarity data. Use Clarity's IP blocking feature to exclude your office IP addresses. For remote teams, consider setting a cookie-based exclusion via GTM.
Monitor after theme changes
Every time you update your Shopify theme, switch themes, or install a new app, check that Clarity is still recording. Theme updates can overwrite custom code in theme.liquid. The GTM method avoids this risk entirely.
Performance considerations
Clarity's script is lightweight (~20KB gzipped) and loads asynchronously, so it shouldn't affect your Shopify store's page speed score. However, if you're running multiple analytics tools (Clarity + Hotjar + FullStory + Lucky Orange), the cumulative effect will slow things down. Stick with one behavior analytics tool — Clarity's free unlimited plan makes this an easy choice.
Building a weekly optimization workflow
Here's a practical workflow for using Clarity data to improve your Shopify store:
- Monday — Review Clarity's frustration signals dashboard. Note the top pages with rage clicks and dead clicks.
- Tuesday-Wednesday — Watch 10-15 session recordings on those pages. Document the patterns you see.
- Thursday — Implement one fix based on what you found (move a button, simplify a form, add a trust badge).
- Next week — Check if frustration signals decreased on the fixed page.
This manual process works, but it's time-consuming. Tools like ClarityInsights automate the analysis step — you get an AI-generated report every Monday with specific, prioritized recommendations based on your Clarity data. No manual session watching required.
Stop analyzing Clarity data manually
ClarityInsights sends you AI-powered weekly reports with per-page analysis, frustration signals, and prioritized recommendations.
Join the Waitlist