
I’ve observed time and again that many Shopify store owners are searching for comprehensive analytics solutions and perhaps an A/B testing tool to gain deeper insights into their stores. While Shopify’s analytics section helps in understanding trends and overall website health, there’s still a need for a more in-depth tool that can explain why a shop isn’t converting. That’s where PostHog on Shopify comes in. In this blog, I’ll show you how we addressed that need using PostHog, at least to start gathering data for now. Although we are aware of PostHog’s Shopify installation documentation, we found it lacking or not suitable for a full-coverage installation. So we wrote our own guide.
Before jumping into the step-by-step PostHog installation guide, make sure you have met these requirements:
- Create your Posthog account, organization, & project
- Have an admin or staff account on Shopify with access to edit customer events.
Step 1: Grab the PostHog snippet
Similar to step 1 in Installing PostHog on WordPress, start by grabbing your PostHog snippet from your project’s settings:
- Log in to your PostHog account.
- Navigate to Project Settings.
- Find the Web snippet section and copy the HTML snippet provided.
Note: If you see person_properties
set to 'identified_only'
in the script, change it to 'always'
for maximum coverage. This ensures that all user interactions are tracked, even for anonymous users.
Step 2: Inject the Snippet into Your Shopify Theme
In Shopify, go to Sales Channels → Online Store → Themes.
Click on the three dots next to your theme’s name and select Edit code.

You will see your theme files there. It will look like this:

In the left sidebar, find and click on theme.liquid.
Paste your copied PostHog snippet just after the opening <head>
tag.
Click Save and exit.
This will ensure that the PostHog tracking script is loaded on every page of your store.
Step 3: Capture Shopify events in PostHog
Capturing native Shopify events like checkout_complete
or checkout_started
is crucial for reliable conversion rate optimization analysis. To do this, we’ll use Customer Events.
- In your Shopify admin dashboard, click on Settings (icon in the bottom left corner).
- Select Customer events from the left sidebar.
- Click the Add custom pixel button.
- In the dialog box that opens enter a name for your pixel (e.g., PostHog).

Configure your pixel’s customer privacy settings according to your store’s privacy policy and compliance requirements.
Paste the following snippet into the code section.
Then to save, click the connect button.

Step 4: Verify Installation
You should now be able to see events like Pageview
, checkout_started
, product_added_to_cart
, and checkout_completed
coming into PostHog:
- Go back to your PostHog dashboard.
- Navigate to Activity or Events to verify that data is being collected.
- Perform some actions on your Shopify store (e.g., add a product to the cart) to test if events are recorded.

Conclusion
By following these steps, you can integrate PostHog with your Shopify store to gain deeper insights into customer behavior and improve your conversion rates. Happy analyzing!
Need further assistance? Feel free to leave a comment below or reach out to us for more help.