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

# Custom scripts

> Add tracking tags and your own code to the pages Anymorph generates.

**Custom scripts** is where you add measurement tags to Anymorph-generated pages. Those pages are served separately from your main site, so the tags on your main site do not follow them. If you want visits and conversions on these pages, enter your IDs here.

<Frame>
  <img src="https://mintcdn.com/opactor/ueicEUgPZ5iGb5FG/images/settings/settings-scripts.png?fit=max&auto=format&n=ueicEUgPZ5iGb5FG&q=85&s=83a090d842531b3df68cf8fdfbe5e8bd" alt="Custom scripts screen with integration ID fields and head and body script boxes." width="1600" height="1151" data-path="images/settings/settings-scripts.png" />
</Frame>

## What's on the screen

### Custom Integrations

Entering an ID turns that integration on; clearing it turns it off. Create the container or property in the tool itself first.

| Field                  | What you paste | Example format |
| ---------------------- | -------------- | -------------- |
| **Google Tag Manager** | Container ID   | `GTM-XXXXXXX`  |
| **Google Analytics 4** | Measurement ID | `G-XXXXXXXXXX` |
| **Meta Pixel**         | Pixel ID       | `1234567890`   |
| **HubSpot**            | Portal ID      | `12345678`     |

A wrongly formatted ID is rejected when you save.

### Custom Code

Two boxes for code you write yourself.

| Field            | Where it goes                                      | Limit |
| ---------------- | -------------------------------------------------- | ----- |
| **Head Scripts** | Into the page head, just before `</head>`          | 10KB  |
| **Body Scripts** | At the end of the page body, just before `</body>` | 10KB  |

The "\[n] / 10KB" counter under each box turns red past the limit and blocks **Save**. A successful save confirms with "Scripts saved successfully".

<Warning>
  This form starts blank every time you open it. It does not read back what you saved before, so pressing **Save** replaces everything with what is on screen right now. Even to change one tag, re-enter every ID and script you use before saving. Keep your own note of what is configured.
</Warning>

## How to use it

<Steps>
  <Step title="Collect your IDs">
    The GA4 measurement ID, the GTM container ID, the Meta pixel ID, the HubSpot portal ID. Copy each from its own admin screen.
  </Step>

  <Step title="Fill in everything, not just the change">
    Because the form opens blank, re-enter every ID and script you want to keep.
  </Step>

  <Step title="Press Save">
    "Scripts saved successfully" means it took. Pages generated from now on carry the tags.
  </Step>

  <Step title="Verify on a live page">
    Open a published page and check the real-time view in your analytics tool.
  </Step>
</Steps>

## FAQ

<AccordionGroup>
  <Accordion title="GA4 is on my main site. Why don't generated pages show up?">
    They are served separately. Enter the measurement ID here to add the tag to them.
  </Accordion>

  <Accordion title="Does this code also run on my main site?">
    No. It applies only to Anymorph-generated pages.
  </Accordion>

  <Accordion title="I reopened the page and the fields are empty.">
    The form doesn't load saved values. Your settings are not lost, but always re-enter everything before saving.
  </Accordion>

  <Accordion title="What if I go over 10KB?">
    The counter turns red and Save is blocked. Trim the code, or load everything through a single tag manager instead.
  </Accordion>

  <Accordion title="Can I tell which visits came from AI answers?">
    See [Performance](/dashboard/performance) and [AI engine conversions](/guides/ai-engine-conversions).
  </Accordion>
</AccordionGroup>

## Related

<CardGroup cols={2}>
  <Card title="AI engine conversions" href="/guides/ai-engine-conversions">Measure traffic that arrives via AI.</Card>
  <Card title="Performance" href="/dashboard/performance">Traffic and outcome numbers.</Card>
  <Card title="Integrations" href="/settings/integrations">Connect GA4 and Search Console.</Card>
  <Card title="Domain" href="/settings/domain">Connect the address that serves your pages.</Card>
</CardGroup>
