← Back to insights
Guide · #740

PostHog for Shopify Founders: Setup and First Funnels

Step-by-step guide to install PostHog on Shopify, track customer journeys, and build conversion funnels. Setup in minutes. Concrete examples included.

Filed
May 11, 2026
Read
14 min
Author
The Seoable Team

PostHog for Shopify Founders: Setup and First Funnels

You shipped. Your Shopify store is live. You're getting traffic. But you don't know where customers drop off, what makes them buy, or why they abandon carts.

That's where PostHog comes in.

PostHog is a product analytics platform built for founders who actually care about data. No black boxes. No opaque dashboards. You own your data, you control the tracking, and you see exactly what's happening inside your store.

This guide walks you through installing PostHog on Shopify, wiring up the events that matter, and building your first three funnels. By the end, you'll have visibility into the customer journeys that drive revenue.

Prerequisites: What You Need Before Starting

Before you touch any code, make sure you have these in place:

Shopify account and admin access. You need to be able to edit your theme and access the Shopify admin. If you're using a custom theme or third-party apps, note that now—it matters for pixel placement.

PostHog account (free tier is fine). Sign up at posthog.com. The free tier gives you 1 million events per month, which is plenty to start. You'll get an API key and project ID immediately after signup.

Basic understanding of Shopify's theme structure. You don't need to be a developer, but knowing where to paste code snippets in your theme editor helps. If you're using a custom theme or Shopify Plus, you might need a developer for one step.

Google Search Console and GA4 already set up (optional but recommended). If you've already set up Google Search Console in 10 minutes and configured GA4 for SEO tracking from day one, PostHog becomes your second layer of insight. You'll track user behavior at a granular level while GA4 handles your traffic overview.

Realistic expectations about tracking. PostHog will show you what customers do on your store. It won't magically increase conversions. But it will tell you why they're not converting, which is worth more than any vanity metric.

Step 1: Create Your PostHog Project and Get Your API Key

This is the foundation. Everything else depends on it.

Go to posthog.com and sign up or log in. Once you're in your dashboard:

  1. Click Settings in the bottom left corner.
  2. Select Project Settings.
  3. Copy your Project API Key. It looks like phc_xxxxxxxxxxxxx. Save this somewhere safe—you'll need it in the next step.
  4. Note your Project ID (visible in the URL or settings page). This is also important.

If you're in the US, make sure your data region is set to US. If you're in Europe, select EU. PostHog respects GDPR and handles data residency correctly, but you need to set it upfront.

That's it for this step. You now have the credentials you need to connect PostHog to Shopify.

Step 2: Install PostHog on Your Shopify Store

You have two paths here: the simple path (recommended for most founders) and the advanced path (if you need custom server-side tracking).

The Simple Path: PostHog Snippet in Your Theme

This is the fastest way. You're adding a JavaScript snippet to your Shopify theme that fires on every page load.

  1. Log into your Shopify admin.
  2. Go to Online Store > Themes.
  3. Find your active theme and click Edit Code.
  4. In the left sidebar, find theme.liquid (or layout/theme.liquid depending on your theme). Click it to open.
  5. Find the closing </head> tag. Paste this code right before it:
<script>
  !function(t,e){var o,n,p,r;e.__SV||(window.posthog=e,e._i=[],e.init=function(i,s,a){function g(t,e){var o=e.split(".");2==o.length&&(t=t[o[0]],e=o[1]),t[e]=function(){t.push([e].concat(Array.prototype.slice.call(arguments,0)))}}(p=t.PostHogAnalytics=t.PostHog||[]).capture=function(){p.push(["capture"].concat(Array.prototype.slice.call(arguments,0)))},p.identify=function(){p.push(["identify"].concat(Array.prototype.slice.call(arguments,0)))},p.API_HOST=s.api_host,p.init(i,s),p.people=new function(){function e(t){p.push(["people"].concat(Array.prototype.slice.call(arguments,0)))}}),p.toString=function(){return"PostHog"},p.load=function(t,e){var o=document.createElement("script");o.type="text/javascript",o.async=!0,o.src=t;var n=document.getElementsByTagName("script")[0];n.parentNode.insertBefore(o,n)},p.loaded=!0,p.config=s,p.get_distinct_id=function(){return p.distinct_id},p.get_session_replay_url=function(){return p.get_distinct_replay_url()},p.has_opted_out_capturing=function(){return!1},p.has_opted_in_capturing=function(){return!0},p.opt_out_capturing=function(){},p.opt_in_capturing=function(){},p.reset=function(){function t(){p.identify("[object Object]"),p.reset()}return p.people.set(p.people.properties),void p.people.delete(),t()},p.get_distinct_id=function(){return p.distinct_id},p.debug=function(t){p.__debug=t},p.verbose=function(t){p.__verbose=t},p.init(i,s,a)}},"undefined"!=typeof document&&(document.addEventListener("DOMContentLoaded",function(){PostHog.load("YOUR_API_KEY",{api_host:"https://us.posthog.com"})}),"undefined"!=typeof window&&window.posthog&&window.posthog.loaded&&window.posthog.config&&(window.posthog.config.loaded=!0))}(window,window.PostHog||[]);
</script>
  1. Replace YOUR_API_KEY with the API key you copied in Step 1.
  2. If your PostHog region is EU, change https://us.posthog.com to https://eu.posthog.com.
  3. Click Save.

That's it. PostHog is now installed on every page of your Shopify store. You should start seeing page views in your PostHog dashboard within 30 seconds.

Pro tip: If you're using a page builder like Pagefly or Gempages, you might need to add the snippet in their custom code section instead of theme.liquid. Check your page builder's documentation.

The Advanced Path: Using Shopify Web Pixels

If you want server-side tracking or need more control, Shopify's Web Pixels API is your tool. This lets you track events directly from Shopify's servers, which means they fire even if a customer has JavaScript disabled or uses ad blockers.

Here's the basic setup:

  1. In your Shopify admin, go to Settings > Customer Events.
  2. Click Add Custom Pixel.
  3. Paste this code:
Pixel.addEventListener('page_viewed', (data) => {
  window.posthog && window.posthog.capture('page_viewed', {
    url: data.url,
    referrer: data.referrer
  });
});

Pixel.addEventListener('product_viewed', (data) => {
  window.posthog && window.posthog.capture('product_viewed', {
    product_id: data.product.id,
    product_title: data.product.title,
    product_price: data.product.price
  });
});

Pixel.addEventListener('cart_updated', (data) => {
  window.posthog && window.posthog.capture('cart_updated', {
    cart_size: data.cart.line_items.length,
    cart_total: data.cart.total_price
  });
});
  1. Save and activate the pixel.

This approach is more robust for e-commerce because Shopify fires these events server-side. They're guaranteed to fire, even if your theme JavaScript breaks. For detailed setup, see the PostHog Shopify integration guide.

Warning: Don't do both the simple snippet AND the Web Pixel at the same time. You'll double-count events. Pick one. For most founders, the simple snippet is faster to set up and sufficient.

Step 3: Verify PostHog Is Tracking Events

Before you build funnels, confirm that PostHog is actually receiving data.

  1. Go to your PostHog dashboard.
  2. Click Events in the left sidebar.
  3. You should see a stream of events flowing in. Look for $pageview events first—those fire automatically.
  4. Visit a page on your Shopify store in a new tab. Refresh it. You should see a new $pageview event appear in PostHog within a few seconds.

If you see events, you're good. If not:

  • Check that your API key is correct in the snippet. Copy-paste errors happen.
  • Make sure you saved the theme.liquid file.
  • Check your browser's console for JavaScript errors (right-click > Inspect > Console tab).
  • If you're using a custom theme or page builder, the snippet might not be in the right place. Move it to the header section of your page builder instead.

Once you confirm events are flowing, move to the next step.

Step 4: Set Up Shopify-Specific Events

Pageviews are nice, but they don't tell you much. You need to track the events that actually drive revenue: product views, add-to-cart, checkout starts, and purchases.

PostHog doesn't automatically capture these Shopify events. You need to wire them up manually using the Web Pixels API or custom JavaScript.

Here's the easiest way using Shopify's Web Pixels:

  1. Go to Settings > Customer Events in your Shopify admin.
  2. Click Add Custom Pixel.
  3. Paste this code:
Pixel.addEventListener('page_viewed', (data) => {
  window.posthog && window.posthog.capture('$pageview', {
    path: data.url,
    referrer: data.referrer
  });
});

Pixel.addEventListener('product_viewed', (data) => {
  window.posthog && window.posthog.capture('product_viewed', {
    product_id: data.product.id,
    product_title: data.product.title,
    product_price: parseFloat(data.product.price),
    product_vendor: data.product.vendor,
    product_type: data.product.type
  });
});

Pixel.addEventListener('cart_updated', (data) => {
  window.posthog && window.posthog.capture('cart_updated', {
    cart_line_items_count: data.cart.line_items.length,
    cart_total_price: parseFloat(data.cart.total_price),
    timestamp: new Date().toISOString()
  });
});

Pixel.addEventListener('checkout_started', (data) => {
  window.posthog && window.posthog.capture('checkout_started', {
    cart_total: parseFloat(data.checkout.total_price),
    line_items_count: data.checkout.line_items.length
  });
});

Pixel.addEventListener('payment_info_submitted', (data) => {
  window.posthog && window.posthog.capture('payment_info_submitted', {
    checkout_token: data.checkout.token
  });
});
  1. Save and activate.

Now PostHog is capturing the events that matter for e-commerce. You'll see product_viewed, cart_updated, checkout_started, and payment_info_submitted events in your PostHog dashboard.

Pro tip: If you're running a Shopify store with a custom checkout (Shopify Plus or headless), you might need to add purchase tracking manually. See the Web Pixels API documentation for more details.

For a more automated approach, you can also use no-code tools like n8n to connect PostHog and Shopify or Converge for server-side tracking, but the Web Pixels approach is simpler for most founders.

Step 5: Identify Customers (Optional but Recommended)

Right now, PostHog is tracking anonymous visitors. To connect events to actual customers, you need to identify them.

Add this code to your theme.liquid or use a Web Pixel:

Pixel.addEventListener('checkout_completed', (data) => {
  if (window.posthog && data.checkout.customer) {
    window.posthog.identify(data.checkout.customer.id.toString(), {
      email: data.checkout.customer.email,
      first_name: data.checkout.customer.first_name,
      last_name: data.checkout.customer.last_name,
      total_spent: parseFloat(data.checkout.total_price)
    });
  }
});

This way, when a customer completes checkout, PostHog ties all their previous anonymous events to their customer ID. Now you can see the full journey from first visit to purchase.

Step 6: Build Your First Three Funnels

Now you have data flowing. Time to see where customers drop off.

A funnel is a series of steps that lead to a goal. For Shopify, the most important funnels are:

  1. Product view to cart (how many people who look at a product add it to cart)
  2. Cart to checkout (how many people who add to cart start checkout)
  3. Checkout to purchase (how many people who start checkout complete it)

Let's build these.

Funnel 1: Product View to Cart Conversion

  1. In PostHog, click Funnels in the left sidebar.
  2. Click New Funnel.
  3. Name it "Product to Cart".
  4. For Step 1, select the event product_viewed.
  5. For Step 2, select the event cart_updated.
  6. Click Save.

PostHog will now show you:

  • How many people viewed products
  • How many of those added to cart
  • Your product-to-cart conversion rate

If this is below 5%, you have a problem. Either your product pages aren't compelling, or your add-to-cart button is hard to find. Test changes and watch this funnel improve.

Funnel 2: Cart to Checkout

  1. Click New Funnel again.
  2. Name it "Cart to Checkout".
  3. Step 1: cart_updated
  4. Step 2: checkout_started
  5. Save.

This shows you cart abandonment. If 70% of people who add to cart never start checkout, you're leaving money on the table. Common culprits: surprise shipping costs, unclear checkout flow, or lack of trust signals.

Funnel 3: Checkout to Purchase

  1. Click New Funnel.
  2. Name it "Checkout to Purchase".
  3. Step 1: checkout_started
  4. Step 2: payment_info_submitted (or purchase if you have it)
  5. Save.

This is your checkout completion rate. Anything below 70% means your checkout flow has friction. Look for:

  • Form validation errors
  • Payment method issues
  • Mobile responsiveness problems

Pro tip: Click on each funnel to see the breakdown by property. You can filter by product type, price range, or traffic source. This reveals which products or customer segments have the worst drop-off.

Step 7: Connect PostHog to Your Existing Analytics Stack

If you've already set up GA4 for SEO tracking from day one or Google Tag Manager without breaking your site, PostHog becomes your second layer.

Here's how they work together:

GA4 tells you where traffic comes from and how much it converts. PostHog tells you why it converts or doesn't.

Google Tag Manager lets you deploy tracking without touching code. PostHog gives you the granular event data that GTM can feed into GA4.

For example:

  • GA4 shows: "Organic traffic converts at 3%."
  • PostHog shows: "Organic traffic viewers add to cart at 12%, but only 25% complete checkout."

Now you know the problem isn't product-market fit; it's checkout friction.

To connect them, you can:

  1. Export PostHog events to GA4 using PostHog's GA4 integration (Settings > Integrations > Google Analytics).
  2. Use GTM to pass PostHog events to GA4 by setting up custom events in GTM that listen to PostHog.
  3. Build a dashboard in Looker Studio that combines GA4 organic traffic data with PostHog funnel data.

If you haven't set up GA4 yet, start with GA4 events for SEO: what to track beyond pageviews to understand what events matter.

Step 8: Set Up Alerts for Broken Funnels

Once your funnels are live, you want to know immediately if something breaks.

PostHog has alerts. Here's how to set them up:

  1. Click on a funnel (e.g., "Product to Cart").
  2. Click the Alert icon (bell) in the top right.
  3. Set a threshold: "Alert me if product-to-cart conversion drops below 4%."
  4. Choose your notification method (email, Slack, webhook).
  5. Save.

Now if your conversion rate crashes (maybe a code change broke your add-to-cart button), you'll know within hours, not weeks.

Set alerts for all three core funnels. This is your early warning system.

Step 9: Track Revenue and Profit (Advanced)

Funnels are nice, but what really matters is revenue. PostHog can track this too.

When a customer completes checkout, capture the purchase event with revenue:

Pixel.addEventListener('checkout_completed', (data) => {
  window.posthog && window.posthog.capture('purchase', {
    revenue: parseFloat(data.checkout.total_price),
    currency: 'USD',
    items_count: data.checkout.line_items.length,
    customer_id: data.checkout.customer.id
  });
});

Now in PostHog, you can see:

  • Revenue by traffic source
  • Revenue by product
  • Revenue by customer segment
  • Revenue trend over time

This is where PostHog becomes your business intelligence tool, not just an analytics tool.

Step 10: Iterate and Optimize

You now have visibility. Use it.

Every week:

  1. Check your three core funnels. Did conversion rates improve? Decline? Why?
  2. Look at drop-off points. Where do most people leave? That's your optimization target.
  3. Test one change. Improve your add-to-cart button. Simplify checkout. Add trust signals. Change one thing at a time.
  4. Measure the impact in PostHog. Did the funnel improve? If not, revert and try something else.

This is how you go from "I have no idea why customers don't buy" to "I know exactly where to optimize."

PostHog doesn't magically increase conversions. But it tells you where the leaks are. Plug the leaks, and conversions go up.

Common PostHog + Shopify Mistakes to Avoid

Mistake 1: Installing PostHog twice. If you use both the theme snippet AND a Web Pixel, you'll double-count events. Pick one method and stick with it.

Mistake 2: Not tracking cart abandonment. Most Shopify stores focus on checkout abandonment but ignore cart abandonment. If 50% of people never reach checkout, that's your real problem.

Mistake 3: Ignoring mobile data. PostHog breaks down events by device. If your mobile checkout conversion is 10% lower than desktop, you have a mobile UX problem. Fix it.

Mistake 4: Setting up events wrong. If your cart_updated event fires multiple times for the same cart (because someone adds two items), your funnel math breaks. Use unique identifiers to deduplicate.

Mistake 5: Not connecting to other tools. PostHog is powerful alone, but it's even better when connected to GA4, Google Search Console, and Looker Studio dashboards. See the full picture.

Bonus: PostHog + SEO Integration

If you're serious about organic visibility, connect PostHog to your SEO stack.

When someone lands on your Shopify store from organic search (Google), PostHog captures that. You can see:

  • Which keywords bring the highest-intent customers
  • Which landing pages convert best
  • Which products get the most organic traffic

To do this:

  1. Set up GA4 linked to Google Search Console to see search queries.
  2. In PostHog, create a funnel filtered by traffic source = "organic".
  3. Compare organic conversion rates to other sources.
  4. Double down on keywords that convert. Cut keywords that don't.

This is how you turn SEO traffic into revenue. Most founders get traffic but don't measure if it converts. You now can.

For a broader SEO foundation, check out the free SEO tool stack every founder should set up today to see how PostHog fits into your complete analytics picture.

What's Next: Scaling Your PostHog Setup

Once you've nailed these three core funnels, you can expand PostHog to track:

  • Email capture (how many people sign up for your newsletter)
  • Product recommendations (which recommended products do people click)
  • Review submissions (do customers leave reviews, and does it affect conversions)
  • Customer lifetime value (which customers are worth the most)
  • Retention cohorts (do customers come back, and why)

But start with the basics. Get the three core funnels working. Optimize them. Then expand.

If you want to accelerate your organic visibility alongside this analytics work, check out Seoable's one-time SEO audit and AI blog generation. You get a domain audit, keyword roadmap, and 100 AI-generated blog posts in under 60 seconds for $99. Combined with PostHog data on what content converts, you can double down on topics that bring high-intent customers.

Key Takeaways

PostHog gives you visibility. You now see exactly where customers drop off in your Shopify funnel.

Setup takes 30 minutes. Install the snippet, wire up four events, build three funnels. Done.

The three core funnels are: product view to cart, cart to checkout, checkout to purchase. Master these first.

Funnels are only useful if you act on them. When you see a drop-off, test a fix. Measure the impact. Repeat.

PostHog works best as part of a stack. Connect it to GA4, Google Search Console, and GTM for the full picture.

Revenue is what matters. Track it from day one. You'll make better decisions.

You now have the tools to see what's actually happening in your Shopify store. Most founders never do this. You will. That's a competitive advantage.

Ship it.

Free weekly newsletter

Get the next one on Sunday.

One short email a week. What is working in SEO right now. Unsubscribe in one click.

Subscribe on Substack →
Keep reading