> Add Plandalf to a Ghost site with Code injection, then add checkout buttons to posts and pages with an HTML card.

Source: https://plandalf.com/docs/websites/ghost

Websites and builders

# Ghost

Paste the Plandalf script into Ghost's site-wide Code injection once, then add a checkout button or an inline checkout to any post or page with an HTML card. Use it to sell courses, products or offers beside your Ghost memberships.

## Add the script

1.  ### Copy the script
    
    Copy it from your checkout's **Share** screen (pick **HTML**):
    
    ```html
    <script async src="https://YOUR-ORG.plandalf.dev/js/plandalf-sdk.js"></script>
    ```
    
2.  ### Paste it into Site footer
    
    In Ghost Admin, open **Settings**, find **Code injection** (under **Advanced**) and click **Open**. Paste the script into **Site footer** and click **Save**.
    
3.  ### Add the button
    
    In a post or page, add an **HTML** card and paste:
    
    ```html
    <button data-plandalf-present="YOUR-CHECKOUT">Buy Now</button>
    ```
    

To load the script on one post only, paste it into that post's own **Code injection** in post settings instead.

## Open a checkout from a button

In the editor, type `/html` or click **+** and choose **HTML**, then paste:

```html
<button data-plandalf-present="YOUR-CHECKOUT">Buy Now</button>
```

Most themes style buttons with a class such as `class="gh-btn"` or `class="kg-btn"`. A link in a Button card can't carry a Plandalf attribute, so link it to your [hosted checkout link](https://plandalf.com/docs/checkouts/links) instead. More options are in [Buy buttons](https://plandalf.com/docs/checkouts/buy-buttons).

## Show a checkout on the page

Add an **HTML** card where the checkout should appear and paste:

```html
<div data-plandalf-mount="YOUR-CHECKOUT" style="min-height: 480px"></div>
```

## Show a deadline timer

In an **HTML** card, add an empty element with your deadline timer's slug. The script draws the live countdown inside it. To charge the deadline timer's current price, add `data-plandalf-apply-promo` with the same slug to your buy button.

```html
<div data-plandalf-promo="YOUR-PROMO"></div>
<button data-plandalf-present="YOUR-CHECKOUT" data-plandalf-apply-promo="YOUR-PROMO">Buy Now</button>
```

In newsletters, use the countdown image from your deadline timer's Emails tab instead. See [Email countdowns](https://plandalf.com/docs/promos/email-countdowns).

## Check it's working

1.  ### Open the published post
    
    Use a private window. In the browser console, type `plandalf`: you should see a function. `undefined` means the script isn't on the page.
    
2.  ### Click your button
    
    The checkout opens over the page.
    
3.  ### Make a test purchase
    
    Add your staging site, or `localhost` for a local Ghost, in Plandalf under **Settings → Advanced → Test domains**. See [Test mode](https://plandalf.com/docs/get-started/test-mode).
    

## If it isn't working

-   Emails Ghost sends don't run scripts. In a newsletter, link to your hosted checkout instead of using a button.
-   If the script shows as text on the page, check it's pasted with its `<script>` tags.
-   Add `data-debug="true"` to the script tag and the console logs each step the script takes.

See [Troubleshooting](https://plandalf.com/docs/help/troubleshooting).

Something wrong or missing? Email [hello@plandalf.com](mailto:hello@plandalf.com).
