Autonnel v1.7.0

Domain custom code

Inject HEAD / BODY_START / BODY_END scripts into every storefront page of one domain.


Custom code is HTML or JavaScript that Autonnel injects into every storefront page of one domain. Each domain keeps its own scripts, so a brand’s pixels and analytics tags never load on another brand’s storefront. Manage them from Pages → Domains: open the domain and use its Custom code tab. Scripts are not shared between domains; to run the same tag on two domains, add it to each. Managing custom code needs the Domains permission.

Injection positions

Each script is assigned one of three positions:

PositionWhere it is injected
HEADInside the <head> element, after meta tags
BODY_STARTImmediately after the opening <body> tag
BODY_ENDImmediately before the closing </body> tag

Scripts within the same position are injected in the order shown. You can reorder them by dragging rows in the settings table.

Adding a script

  1. Go to Pages → Domains and click Custom code on the domain’s row.
  2. Click Add script.
  3. Enter a name (used only in the admin list, not rendered to the page).
  4. Select a position from the dropdown.
  5. Paste your script content. This should be a complete <script> tag or a <noscript> fallback block, not bare JavaScript.
  6. Click Add script.

The script is enabled by default. You can disable a script without deleting it by unchecking its row. Deleting a domain deletes its custom code. A host that is not bound in Pages → Domains gets no custom code.

Upgrading from site-wide scripts

Before custom code moved onto domains, scripts ran on every domain. npx autonnel pages:backfill-domains, the one-time step of the domains upgrade, copies each existing script onto every existing domain, so storefronts keep their tags; afterwards edit or remove each domain’s copy separately. A deployment with no domain yet gets the copies when its first domain is added. Run it before deploying the new build, as the upgrade notes say: run afterwards, storefronts keep serving their cached script list until any custom code is saved or for up to 12 hours.

Common use cases

Analytics

Paste your Google Analytics, Plausible, or Mixpanel loader into the HEAD position:

<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());
  gtag('config', 'G-XXXXXXXXXX');
</script>

Advertising pixels

Paste a Meta Pixel base code or TikTok Pixel base code into HEAD or BODY_START. The pixel fires on every page load. Per-funnel event-specific pixels (Purchase, AddToCart) are configured separately in Funnel → Ads, not here.

Custom interaction JavaScript

If you need a script to run after the DOM is ready, use BODY_END:

<script>
  document.addEventListener('DOMContentLoaded', function () {
    // your code
  });
</script>

Script ordering relative to funnel scripts

Funnel scripts (configured per funnel in Funnel → Scripts) are injected after site-level scripts within the same position. The full injection order for a given position is:

  1. The domain’s custom code (this page), ordered by their order field
  2. Funnel scripts for the current funnel, ordered by their order field

This means a site-level Meta Pixel base code in HEAD always loads before a funnel-specific Meta Pixel event script in HEAD.

Caveats

  • Scripts in the HEAD position are render-blocking by default. Use the async or defer attribute on <script> tags unless the script explicitly requires synchronous execution.
  • A script that throws a JavaScript error in BODY_START can block subsequent scripts in that position. Test scripts in isolation before enabling them site-wide.
  • Custom code runs on every storefront page of its domain: landing pages, checkout, upsell, thank-you, and error pages. If a script should only run on specific page types, use a funnel script instead, or add a conditional check inside the script content.
  • Conflicts between site-level and funnel-level pixels can cause double-fires. If you have a Meta Pixel in both global scripts and a funnel script, verify that one fires the base code and the other fires only the event, not both.
  • Funnel scripts — per-funnel script injection
  • Domains - per-domain store name, logo, favicon and email sender