Add tracking codes to your site

  • tracking
  • analytics
  • google-tag-manager
  • customizer
  • embeds
  • facebook-pixel

Updated

To add Google Tag Manager, the Meta (Facebook) Pixel, or another tracking code to WordPress, load it once on every page: through your theme's tracking settings, a plugin built for that tool, or a plugin that adds code to your site's header. Whichever you use, load each tool only one way, or every visit is counted twice.

On a Dirigible site, tracking codes go in Appearance → Customize → Scripts & Embeds, so you don't need a plugin. If the vendor gives you an ID, use the matching ID field. Use Custom Embeds only when you have to paste a full snippet of code.

Open the right panel

  1. Go to Appearance → Customize.
  2. Open Scripts & Embeds.
  3. Open Analytics & Tracking for IDs, or Custom Embeds for full snippets.
  4. Click Publish when you're done.

Which tracking ID goes in which field?

Paste the ID into the matching field. Each field also accepts the vendor's full install code and keeps just the ID. Leave fields you don't use blank.

Field What to paste Looks like
Google Analytics ID GA4 Measurement ID G-XXXXXXXXXX
Google Tag Manager ID GTM container ID GTM-XXXXXXXX
Facebook Pixel ID Meta Pixel ID digits only
LinkedIn Partner ID LinkedIn Insight Tag partner ID digits
StackAdapt ID StackAdapt pixel ID as provided by StackAdapt
Hotjar ID Hotjar site ID digits
HubSpot Portal ID HubSpot Hub ID, from your HubSpot tracking code. Also set HubSpot Region if your account is in the EU. digits
Piwik PRO Account Address and Piwik PRO Container ID Your Piwik PRO account address and the site's container ID example.piwik.pro and a long code with dashes

Two fields on the same panel are for proving you own the site, not for tracking visitors:

Field What to paste
Google Site Verification ID Google's HTML-tag verification meta tag, or just the code inside content="…". See Add your WordPress site to Google Search Console.
Facebook Domain Verification ID The token from Meta's domain verification meta tag.

To create a GA4 Measurement ID and check that data arrives, see Add Google Analytics 4 to WordPress.

Google Analytics or Tag Manager, not both

When Google Tag Manager ID is filled in, Dirigible loads Tag Manager and ignores Google Analytics ID. If you use Tag Manager, add your GA4 tag inside Tag Manager and leave Google Analytics ID empty.

When tracking loads

Control What it does
Tracking Load Strategy After Page Load (default and recommended), or First Interaction to wait until the visitor first clicks or scrolls. With First Interaction, visitors who leave without clicking or scrolling aren't counted, which skews bounce rate.
Track Admin Sessions Leave off on a live site so your own logged-in browsing isn't counted. Turn it on only while testing.
Enhanced Ecommerce Tracking With WooCommerce, sends purchases to GA4 or Tag Manager when an order completes.
Ecommerce Debug Mode Prints ecommerce events to the browser console. For testing only.

If the GDPR Banner is on, these ID-based trackers wait until the visitor accepts cookies. See Set up a GDPR cookie consent banner.

What if the tool has no ID field?

Use Scripts & Embeds → Custom Embeds when a tool has no ID field, or your agency sends a full install snippet. Paste it into Tracking Embed, or the head, body, or footer field the vendor names, exactly as supplied. Full steps: Add scripts and chat widgets to your site.

Custom Embeds load as pasted. They don't follow Tracking Load Strategy and don't wait for the GDPR Banner, so use an ID field whenever one exists.

Common mistakes

  • Loading the same tool through an ID field and a Custom Embed (or a plugin). Remove the old pasted code once the ID field is filled in.
  • Filling in Google Analytics ID while Tag Manager is in use. It's ignored; add GA4 inside Tag Manager instead.
  • Pasting the same snippet into a Custom Embed and a page block. Loading it twice breaks widgets and skews reports.
  • Leaving Track Admin Sessions on for a live site.

How do I test a new tag?

Add one tag at a time, then check it in a private window (accept the cookie banner first if it's on). Embed Fonts also lives under Scripts & Embeds, but it isn't a tracking code.

Not sure which box to use? See Which box does my code go in?