Free guide + video walkthrough

Set Up Meta Pixel + Conversions API in GTM Using Claude

Browser and server-side tracking for your Facebook ads, built inside Google Tag Manager by Claude Code. You review the plan, test it, and publish.

Get the PDF that tells Claude how to build your tracking

Upload it to Claude Code and it sets up your Pixel and Conversions API in Google Tag Manager. You'll also get an email invite to create your free Stape server.

We'll email you the PDF and occasional marketing tips. Unsubscribe any time.

Most tracking tutorials walk you through Google Tag Manager one click at a time. You have to work out which events to send to Meta, then build every tag, trigger and variable yourself. If you're not technical, that's a big job.

This guide is different. You'll get Claude, specifically Claude Code, to build the entire setup for you inside Google Tag Manager: browser tracking with the Meta Pixel, and server-side tracking with the Conversions API. Your part is to create two empty containers, answer a few questions, approve the plan, and test that it works.

In this guide

VideoStep
01:26How tracking works, and why browser-only isn't enough
06:35Step 1: Create your two GTM containers
11:10Step 2: Install Claude and create your Stape server
15:55Step 3: Connect Claude to Stape and upload the PDF
19:36Step 4: Give Claude your container IDs
20:56Steps 5 and 6: Claude maps your website
23:19Step 7: Review and approve the event plan
25:59Step 8: Pixel ID, access token and server URL
28:41Step 9: Test everything
41:16Add your own tracking subdomain
43:45Step 10 (optional): Send the data to GA4

How Meta tracking works, and why browser-only isn't enough

If you already know the difference between browser and server tracking, skip to Step 1.

Browser tracking

Meta gives you a script, the Pixel. You install it on your website. When someone lands on a page, the script collects things like their device and IP address, sets cookies, and sends that back to Meta. Meta uses it to say "this person clicked your ad, and now they've become a lead" and credits the conversion inside your ad account.

This worked without problems for a long time. Then iOS 14 arrived. Apple devices started stopping Meta's code from running, and Apple cut the life of its cookies, sometimes to a single day. If someone comes back to your site a few days after clicking an ad, the Pixel no longer has the cookie that ties them to that ad. Ad blockers add to the problem, because they know exactly what Meta's script looks like.

Server-side tracking

With server-side tracking you stop relying on Meta's script to collect the data. You collect it yourself, send it to your own server, and your server passes it to Meta.

Apple and ad blockers can block a Meta script. What they can't really do is stop you collecting information about your own visitors with your own system. So in this setup:

  1. Google Tag Manager collects the data in the browser: name, email, phone, IP, and the Facebook cookies.
  2. It sends that data to your own server.
  3. Your server forwards it to Meta through the Conversions API.

Once the data is on your server you own it. You can send it to Meta, Google Analytics, Google Ads, or anywhere else.

There are two other benefits. Your site can get faster, because you don't need every platform's JavaScript library loading in the browser. And you decide exactly what each platform receives, so you can limit it to what they need.

What you need before you start

Everything you need to open or download:

WhatWhere to get it
Google Tag Managertagmanager.google.com
Claude desktop app (includes Claude Code)claude.com/download
Claude extension for ChromeChrome Web Store
Setup PDF for ClaudeFill out the form on this page, it arrives by email
Stape account for your serverThe invite arrives by email after the same form. Stape's site is stape.io
Stape connector for Claudehttps://gtm-mcp.stape.ai/mcp (also inside the PDF)
Meta Events Managerbusiness.facebook.com/events_manager2
Tag Assistant Companion (testing)Chrome Web Store
Meta Pixel Helper (testing)Chrome Web Store

You also need a Meta Pixel, which Meta now calls a dataset, already created in Events Manager.

Step 1: Create your two GTM containers

You need two containers: a web container that collects information about your visitors, and a server container that sends it to Meta.

The web container

  1. Go to tagmanager.google.com and click Create Account.
  2. Name the account after your company and enter your website as the container name.
  3. Choose Web as the platform and create it.
Google Tag Manager container setup with Web selected as the target platform
Name the container after your website and choose Web.
  1. Install Google Tag Manager on your site. If you use a platform like WordPress you can use a plugin, but we prefer Install manually: copy the code and add it to every page, immediately after the opening <head> element. If you're not sure how, send the snippet to your developer.
  2. Enter your website in the test box to confirm it's installed.
Google Tag Manager manual install screen showing the code snippet to add after the head element
Install manually: copy the snippet onto every page, right after the opening head element.

Even if you only want server-side tracking, you still need the web container. It's what collects the data in the first place. You just won't use it alone to send data to Meta.

If you already have a web container on your site, use that one.

The server container

  1. In GTM, go to Admin and create a new container.
  2. Name it something like "Your Company Server" and choose Server.
  3. When asked how to set up the tagging server, choose Manually provision tagging server.
  4. Copy the container configuration code it shows you and save it. You'll paste it into Stape in the next step.
Google Tag Manager server container setup with Manually provision tagging server selected and the container config shown
Choose Manually provision tagging server, then copy the container config.

Step 2: Install Claude and create your Stape server

Download the Claude desktop app if you don't have it yet.

Then fill out the form on this page. You'll receive two emails:

  • The PDF. These are the instructions Claude follows. It asks you a few questions about your industry, your Pixel and your site, then builds the tracking.
  • A Stape invite. This is where you create the server that sends your data to Meta.

Create the Stape container

  1. Open the Stape email, set your password and log in.
  2. Create a new sGTM container and name it after your company.
  3. Go back to GTM, switch to your server container, and copy the container configuration code from Step 1.
  4. Paste it into Stape, leave the server location on the regional default, and click Create.
Stape new sGTM container screen with the Manually option selected and a field for the container config
In Stape, choose Manually and paste the container config from Google Tag Manager.
  1. Pick a plan.

The free plan is fine for a small site or for testing. If you know you get a lot of traffic, the Pro plan is $20 a month.

Stape subscription plans showing the Free plan with 10,000 requests and the Pro plan at 20 dollars a month
The Free plan covers 10,000 requests a month. Pro is $20.

When it's done, Stape shows the container as active and running.

Step 3: Connect Claude to Stape and upload the PDF

Three small things to set up, then Claude takes over.

Add the Stape connector

  1. Open the PDF and copy the connector link inside it: https://gtm-mcp.stape.ai/mcp
  2. In the Claude desktop app, open Connectors and click Add a connector.
  3. Name it "Stape" and paste the link into the MCP server URL field.
  4. When asked, choose Sign in now, then Register automatically, and complete the Google sign-in.

Leaving the permission setting on "ask first" is fine. Claude will check with you before it does anything major.

Claude desktop app connector settings showing the Stape connector and its tool permissions
The Stape connector once it's added in Claude.

Install the Claude extension for Chrome

Add the Claude extension from the Chrome Web Store. This lets Claude open your website, look at your pages and forms, and work out which events to track and what should trigger them. Without it, Claude can't analyze your site.

The Claude extension page on the Chrome Web Store
The Claude extension on the Chrome Web Store.

Create an empty folder

Make a new folder anywhere on your computer and call it something like "tracking". Claude uses it to save any code it writes.

Start the conversation

  1. In the Claude desktop app, open Claude Code and start a new conversation.
  2. Choose this computer as the environment, click Open folder, and select the folder you just made.
  3. Click Trust workspace.
  4. Upload the PDF.

Why Claude Code and not a normal chat? Tags, triggers and variables in GTM are mostly code. Claude Code understands them, so if something goes wrong with the connector or a tag, it can look at the problem and help you fix it.

Step 4: Give Claude your container IDs

After reading the PDF, Claude needs to know which containers to work in. Copy the container ID from the top of GTM for each one and send both:

Message to Claude
Web container: GTM-XXXXXXX
Server container: GTM-YYYYYYY

If you only have one GTM account connected, Claude may find them without asking.

Claude Code confirming the web and server container IDs in a table and asking for the website URL
Claude confirms both containers, then asks for your website.

Steps 5 and 6: Claude maps your website

Claude will ask for your website URL. Give it the page your ad traffic actually lands on. If your Facebook ads send people to a specific landing page, use that. If they go to your main site, use that.

Claude then opens the site, maps it out, and asks if it can submit your form with test data. This is how it learns which fields exist and what should count as a lead. It tells you the exact details it plans to use.

You'll see the cursor move by itself as Claude clicks through your form. Each prompt in this build takes between one and five minutes, so it's a good time to check your email.

Claude filling out a quote form on a demo home services website through the Chrome extension
Claude working through the form on the demo site by itself.

Step 7: Review and approve the event plan

This is the part you need to read. Claude comes back with a list of every event it plans to send. For the demo site in the video, a home-services lead form, the plan looked like this:

What the visitor doesEvent sent to MetaType
Lands on a pagePageViewStandard, browser and server
Answers the first form questionLead form startCustom
Clicks the phone numberContactStandard
Submits the full formLeadStandard
Submits as a homeowner who needs service todayQualified leadCustom, server only

You can change any of it by typing. Rename a custom event, turn a custom event into a standard one, or tell Claude to remove an event you don't want to send.

Claude's proposed tracking plan table listing each event, when it fires, and whether it is sent from the browser and the server
Claude's proposed tracking plan. Read it before you approve.

Why the qualified lead event matters

You don't always want Meta optimizing for every lead. You want more of your best leads.

Here Claude noticed that a homeowner who needs service today is a hot lead, so it sends a separate event when that happens. That gives you two options in Ads Manager:

  • Keep optimizing for Lead, and add the qualified lead event to your columns to see which ads and campaigns bring in the hot ones.
  • Once you have enough volume, optimize for the qualified lead event itself, so Meta goes looking for more of those people.

When you're happy with the plan, tell Claude to approve and build it.

Step 8: Give Claude your Pixel ID, access token and server URL

Claude now asks for a few details.

  • Meta Pixel ID. In Events Manager, open your dataset and copy the ID.
  • Conversions API access token. In Events Manager, go to Settings, scroll down to the Conversions API section, and click Generate access token.
Meta Events Manager dataset settings with the Generate access token button
Events Manager, Settings tab: scroll down to Generate access token.
  • Server URL. In Stape, open your container and copy the tagging server URL it gives you. You'll swap this for your own subdomain later.
Stape container settings showing the tagging server URL under Domains
Your tagging server URL is under Domains in the Stape container.
  • GA4 measurement ID. You don't need a real one for Meta tracking to work. If you're not setting up GA4, tell Claude to use a dummy one.
Message to Claude
Facebook Pixel ID: 1234567890
FB API token: (paste your token)
sGTM URL: https://your-container.stape.io
GA4 measurement ID: use a dummy one

Claude then builds everything in both containers: the tags, the triggers, and the variables that pull the email, phone number, first name and last name from your form.

Step 9: Check the build, then test it

Claude works in its own workspace in each container, separate from your default one. Use the workspace dropdown in GTM to switch to it. It will have a name that mentions Meta.

Google Tag Manager workspaces list showing the default workspace and the Meta CAPI Build workspace Claude created
Pick the workspace Claude created, not the default one.

Check the server container

  1. Open Tags. You'll see one Conversions API tag per event. Open one and confirm it has your Pixel ID, an access token, an event ID and the page location.
Server container tag list with one Facebook Conversion API tag per event
Server container: one Conversions API tag for each event.
  1. Check the country value. If it's fixed to US and you're somewhere else, change it.
  2. Open Variables and paste your access token into the access token variable. Claude often leaves a placeholder here because it avoids handling secret keys. That's normal.
  3. Confirm the Pixel ID variable is correct.
  4. Go to Admin, then Container Settings, paste your Stape server URL, and save.
Server container settings in Google Tag Manager with the server container URL field
Admin, Container Settings: this is where the server URL goes.

Check the web container

Switch to the web container, select Claude's workspace, and open Tags. You'll see two groups:

  • Tags labelled Meta send data straight from the browser to Meta. This is your browser tracking.
  • Tags labelled GA4 send data to your own server. Despite the name, they have nothing to do with Google Analytics here.
Web container tag list showing GA4 tags that send to the server and Meta tags that send from the browser
Web container: GA4 tags go to your server, Meta tags go straight to Meta from the browser.

The GA4 tag is used because it already collects the visitor information you need, and it has a setting that redirects where that information goes. When that parameter is named transport_url, the tag sends everything to your server and not to Google. If Claude named the parameter something else, rename it to transport_url.

The Google Tag configuration parameter named transport_url pointing at the server container URL
The transport_url parameter is what redirects the data to your server.

Then open Variables and fix the GA4 measurement ID. It can't stay as the placeholder Claude left, or the setup will fail. Use your real ID, or if you're not using GA4, put in G-123456.

Run the test

Always preview the server container first, then the web container.

  1. In the server container, click Preview. The debug screen opens on your Stape address.
  2. In the web container, click Preview and enter your website.
  3. Check the page view. In the web preview, click Container Loaded. You should see the Meta base pixel, the Meta PageView, and the tag that sends the page view to your server. In the server preview you should see a PageView marked Succeeded. If you open the outgoing request, the response code should be 200.
  4. Do every action from your plan on your site: click the phone number, start the form, submit the form. After each one, a new event appears in the left sidebar of both previews. Confirm the right tags fired and succeeded.
  5. Submit the form in the way that should count as a qualified lead and confirm that event fires too.
Web container preview showing the Meta Pixel Base, Meta PageView and GA4 Google Tag fired on Container Loaded
Web preview: the Pixel, the PageView and the server transport tag all fired.
Server container preview showing the Meta CAPI PageView tag succeeded
Server preview: the PageView tag succeeded.
Server container preview showing the Meta CAPI Lead and QualifiedLead tags fired after a form submission
After submitting the form: Lead and Qualified Lead both fired from the server.

Two Chrome extensions make this easier. Tag Assistant Companion opens the preview in its own tab. Meta Pixel Helper shows which Pixel events fired on the page.

Check the customer data

In the server preview, open the Lead event and look at the outgoing request. You'll see values like ph for phone and em for email, each one a long unreadable string. That's correct. The details are hashed before they're sent, and Meta matches them against Facebook profiles on its side.

This is the part most setups miss. If you send a Lead event with no name, email or phone attached, the box is ticked but Meta has far less to work with when it optimizes your campaigns.

Add your own tracking subdomain

So far your server runs on a Stape address. The point of server-side tracking is to keep things first-party, so move it to your own domain. You can do this on the free plan.

  1. In Stape, open your container and click Add new under custom domains.
  2. Enter a subdomain, not your root domain. Common choices are ss.yourdomain.com, gtm.yourdomain.com or sgtm.yourdomain.com. The name is only a label, but it must not already be in use.
  3. Choose the automatic option. Stape logs you in to your domain provider and adds the DNS record for you.
Stape Add custom domain dialog with a subdomain field and the automatic connection option selected
Enter a subdomain and leave the connection on automatic.
  1. Wait for it to show as verified. It usually takes about an hour and can take up to a day.
  2. In GTM, open the server container, go to Admin, then Container Settings, and replace the Stape URL with your subdomain. It has to start with https://.
  3. Preview the server container again. The debug screen should now open on your own subdomain.
  4. Run all the same tests again.

Always retest after a change. When live traffic is running is not the time to find a problem.

Step 10 (optional): Send the same data to GA4

If you also want these events in Google Analytics, add one tag in the server container.

  1. In the server container, go to Tags and create a new tag.
  2. Choose Google Analytics: GA4.
  3. Enter your real measurement ID, not the dummy one.
  4. For the event name, select the built-in Event Name variable. The tag will then send the same events you're sending to Meta.
Server container GA4 tag with the Event Name variable selected
Use the Event Name variable so every event carries through.
  1. For the trigger, create a custom trigger that fires when Client Name equals GA4.
Custom trigger configured to fire when Client Name equals GA4
The trigger: Client Name equals GA4.
  1. Save.

Publish both containers

Nothing is live until you publish.

  1. In the server container, click Submit. GTM writes a version name and description for you. Publish it.
  2. Do the same in the web container.

Common mistakes to avoid

  • Clicking "Automatically provision tagging server" when you create the server container
  • Leaving the access token as a placeholder in the server container's variables
  • Leaving the GA4 measurement ID as Claude's placeholder
  • Leaving the country set to US when your business is somewhere else
  • Previewing the web container before the server container
  • Expecting Meta Pixel Helper to show server events
  • Putting the tracking server on your root domain, or on a subdomain that's already taken
  • Forgetting to publish both containers after testing

Want us to do it with you?

If this feels like too much, you can book a call with Cedric. We can go through the whole setup together, finish one you've started, or review yours to make sure everything is connected properly. One call is usually enough.

Book a 1-on-1 call with Cedric

Get the PDF that tells Claude how to build your tracking

Upload it to Claude Code and it sets up your Pixel and Conversions API in Google Tag Manager. You'll also get an email invite to create your free Stape server.

We'll email you the PDF and occasional marketing tips. Unsubscribe any time.