Snipcart + Ghost

How to use Ghost and Snipcart together

Build a fully customisable ecommerce solution into your Ghost publication with a Snipcart integration

Snipcart is a shopping cart solution that allows developers to turn any website into a robust ecommerce platform in minutes. It’s a developer friendly experience that unlocks the power and flexibility to incorporate products into your site’s content. Using the code injection feature within Ghost, it’s entirely impossible to integrate with Snipcart directly and start selling products and services from your site.

Sign up for a Snipcart account

Snipcart offer two payment options, with 2% fees on each purchase or fixed fees. Check out their pricing page and sign up for your Snipcart account. Alternatively, you can try out the software for free in test mode.

Once you have signed up, grab your code snippet from the Snipcart dashboard which looks like this with your API key in place:

<script src=""></script>

<script src="" data-api-key="YOUR_API_KEY" id="snipcart"></script>

<link href="" rel="stylesheet" type="text/css" />

You’ll find this information inside the API keys area of your account:

Note that your account and API key will be in test mode by default. You can use test mode for free completely unlimited. To switch to live, you’ll need to add a credit card, and then implement Snipcart using the live API key.

Use Ghost Code Injection

In Ghost you can inject code across your entire site or on an individual post or page. Snipcart requires a single piece of code to be implemented across your site, so that you’re able to manually add products on posts or pages as required. To do this, we’ll use the global code injection feature which can be found in the Ghost Admin settings menu:

Note: We’re using Site Footer instead of the Header because the default Ghost theme includes jQuery which is not visible in code injection, and must always be above Snipcart’s .js file.

Your site is now fully integrated with Snipcart and you can turn any element on your site into buyable products using code 🎉

Use product attributes in your site’s HTML

Since Snipcart is a sensible developer tool - once your code snippet is in place you can then store products directly inside your website’s HTML code.

This can be done using an HTML card inside the Ghost editor on any page or post:

Alternatively, you can place your Snipcart code directly into your Handlebars theme or your custom front-end if you’re using Ghost as a Headless CMS.

How does it work?

All of your product information is stored in the HTML markup. You can basically convert any link or element into a buy button. Here’s an example of the geek shirt button from Snipcart’s homepage:

    data-item-name="The Geek shirt"
    data-item-description="Be the coolest geek in town with this awesome shirt">
    Try the cart!

You can preview a Snipcart buy button in action on their homepage - when a visitor clicks the buy button it looks something like this:

Allow your readers to buy products without having to leave your site!

Allow your readers to buy products without having to leave your site!

For more information about creating custom attributes, check out the Snipcart documentation.