> ## Documentation Index
> Fetch the complete documentation index at: https://www.pagent.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Shopware

> Add pagent to your Shopware 6 shop with a head-code plugin or a theme template.

Shopware 6 has no built-in field for custom head code. You add pagent with a plugin from the Shopware Store, or with a small change to your theme.

Copy your pagent snippet. You find it in the install step after you start your trial, and any time later in pagent under **Settings → Setup**. It looks like this, with your own client key:

```html theme={"dark"}
<script
  src="https://cdn.pagent.ai/js/sdk.js"
  data-client-key="YOUR_CLIENT_KEY">
</script>
```

Paste it unchanged. Don't add `async`, `defer` or `type="module"`: pagent needs to load before your page shows, so visitors never see the original flash.

## Option 1: a head-code plugin

This works without a developer.

**1. Find a head-code plugin**

In the Shopware Store, search for a plugin that adds custom scripts or HTML to the `<head>`, for example with the words "custom scripts", "HTML head" or "tracking code".

**2. Install it**

In your Shopware admin, go to **Extensions → My extensions**, then install and activate the plugin.

**3. Paste the snippet**

Open the plugin's configuration and paste your snippet into its head field. If it asks where to place the code, choose the head, as early as possible.

**4. Save and clear the cache**

Save, then clear the shop cache under **Settings → System → Caches & indexes**.

> [!NOTE]
>
> These plugins come from other providers, not from Shopware or pagent. Choose one that is compatible with your Shopware version.

## Option 2: your theme (for developers)

In your own theme or plugin, extend the storefront's `meta.html.twig` and add the snippet to the `layout_head_meta_tags` block, at the top of `<head>`:

```twig theme={"dark"}
{# src/Resources/views/storefront/layout/meta.html.twig #}
{% sw_extends '@Storefront/storefront/layout/meta.html.twig' %}

{% block layout_head_meta_tags %}
    {{ parent() }}
    <script
        src="https://cdn.pagent.ai/js/sdk.js"
        data-client-key="YOUR_CLIENT_KEY">
    </script>
{% endblock %}
```

Then clear the cache, for example with `bin/console cache:clear`.

> [!NOTE]
>
> pagent runs on your storefront pages. Your checkout pages are part of the storefront in Shopware too, so the snippet loads there as well.

## Check it worked

1. Open your site in a private browser window, so no cached version shows.
2. Back in pagent, click **Check connection** in the install step. If you've finished setup already, open **Settings → Setup**: it shows **You are ready** once pagent has received visits from your site.
3. pagent loads your live site and looks for the snippet. When it finds it, you can start your first test.

> [!TIP]
>
> pagent couldn't find the snippet? Make sure you published or saved the change on your live site, then check again. If you installed it through Google Tag Manager, open your site once in a normal browser window first.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.