Nov 23, 2026
Written by
Ieva Dubricke
Key takeaways
Imagine you spend a whole weekend building a beautiful new booking page in Replit, launch it and then go on to kick off a Meta ad campaign on Monday. By Tuesday morning the Replit Growth dashboard is showing 300 visitors coming in from Facebook, but Meta Events Manager is showing zero conversions. The issue is that Meta Events Manager just isn't seeing the data coming in from Replit.
This guide will explain to you how to avoid a situation like this. We'll take you step by step through the process of setting up a demo project from the beginning, integrating Google Tag Manager, and routing the GA4 and Meta events through a server-side container. You can also easily carry out these exact steps with any project you already have.

Replit is a browser-based platform where the Replit agent transforms a simple prompt into a fully functional application. By describing your vision, the agent builds both the frontend and backend, allowing you to publish your project instantly to a Replit URL or a custom domain. Creators use it for everything from landing pages and internal tools to full-scale SaaS products.
A web app comes equipped with built-in website analytics called Project Analytics, which you can easily find under Tools → Growth:
For a brand-new application, these built-in insights are great for checking basic traffic and user activity. However, they stop being sufficient as soon as you start investing in paid advertising.
When you're working with ad platforms you need conversion data. Meta uses Pixel and Conversions API events to link their ads to real customers. GA4 requires the hits to be delivered directly to its property. Google Ads requires conversions to be linked to a specific click. A booking recorded in the Replit Growth dashboard is useful for your own internal insights but is completely invisible to the ad networks. That's the exact gap that needs to be bridged for apps built on Replit from the very first moment you start running marketing campaigns.
So, when considering analytics for apps built with Replit, there are a couple of primary ways to implement tracking besides the default built-in dashboard:
Here's how the two options compare with Replit's built-in Project Analytics:
| Setup and effort | Ad-blocker and ITP resistance | Managing and updating tags | Where data goes | |
|---|---|---|---|---|
| Replit Project Analytics | Low (built-in; enable upon publishing) | Not applicable | Not applicable | Replit's Growth dashboard only |
| Tags added to the app code | Low (ask agent to paste code) | Low (vulnerable to ad blockers and Safari ITP) | Moderate (requires editing code and republishing) | GA4/Meta/Other platforms (browser-side) |
| GTM with a Stape server container | Moderate (configure GTM and Stape) | High (routes securely through your own tagging server) | Moderate (managed directly in GTM, no code republishing needed) | GA4/Meta/Other platforms (server-side) |
The main drawback of this third approach is the setup time. Manually building two containers, configuring a server host, and setting up a full suite of tags can easily consume an afternoon – or much longer if you are new to GTM. However, with Stape's free MCP servers connected, Replit handles all of that for you.
On its own, Replit Agent can only change what's inside your project. It can integrate the tracking code, but it can't open Google Tag Manager or create a server container. This is where MCP (Model Context Protocol) bridges the gap, serving as an open standard that allows AI assistants to securely call external APIs and take action across different services. To make this possible, Stape provides free, open-source MCP servers for Google Tag Manager and Stape. For more information, check out our guide on Stape's AI Assistant and free MCP servers.
In Replit, MCP servers are connected at the account level. Once you connect the GTM and Stape servers, the Replit agent can utilize them across every app you build – not just your current project. This transforms GTM setup from a tedious configuration task into a simple conversation: you simply describe the tracking you need. This is what Stape and GTM MCP servers are capable of doing:
These MCP connections also stay completely secure and out of your live application. Replit keeps your working environment strictly separate from the published deployment, meaning the servers are only accessible to the agent while you build. Visitors will never interact with them, and your Google sign-in details or Stape API key will never make it to the published site.
Once your app is live, the tracking operates like server-side tagging on any other professional website. Instead of sending data directly to GA4 and Meta, the browser routes events to your dedicated Stape tagging server, which then securely forwards them to the platforms of your choice. Because every request passes through a server under your direct control, fewer valuable events are lost to ad blockers and browser privacy restrictions, giving you complete control over what data each platform receives.

You’ll need to have the following:
G-XXXXXXXXXX). If you don't have the published site yet, just use the replit.app address for now when setting up. By the end of the tutorial you'll be able to replace it.Skip this step if you're working on an existing project.
1. In Replit, send this prompt:
Build a one-page site for Picket, a fictional kayak rental on Picket Lake. At the top, a short headline and two sentences about renting a kayak for a quiet morning on the lake. Below that, a form with name, email, and preferred date, and a button labeled "Request a kayak." After a successful submit, replace the form with a short confirmation that repeats the date they chose. Realistic sample copy. Calm, outdoorsy design. No other pages, no payment, no account, and no database.

2. When the preview loads, fill in the form and check that the thank-you message appears.

1. At the bottom of the screen click on your account → Settings.

2. Click Integrations → Your integrations → Add custom → Add personal MCP server.

3. Fill in the following:
GTMhttps://gtm-mcp.stape.io/mcpIf you'd like to scan our MCP for the prompt injection, leave the checkbox checked.
4. Click Test & save.

5. Click Authorize GTM and sign in with the Google account that has access to GTM.

6. Repeat steps 1-2 and now add a Stape MCP:
Stapehttps://mcp.stape.io/mcp Open Advanced settings and click Add header. In Header Name enter Authorization, and in Header Value enter your API key.
If you'd like to scan our MCP for the prompt injection, leave the checkbox checked.
7. Click Test & save.

8. To check the connections, ask in the project chat:
Using the GTM connector, how many containers do I have?
Using the Stape connector, how many containers does my account have?
If you're starting with an empty Stape account, the answer is 0. The next step creates your first container.

1. Enter the following prompt and replace the server zone, measurement ID and Meta Pixel ID with your own. Choose the server zone nearest most of your visitors so requests to your Stape container travel a shorter distance. This ensures faster data transmission, helping to prevent event loss – especially for users on slower connections. For the full list read the Server zones for sGTM article.
Using GTM and Stape connectors, set up the tracking foundation for this project:
1. Create the containers. Create a web container named "Picket web" and a server container named "Picket server". Host the server container on Stape in the EU West zone, on the free plan.
2. Connect Google Analytics. Set up GA4 for measurement ID G-XXXXXXXXXX so the website sends its data to the server container first, and the server then forwards it to Google Analytics.
3. Add Meta. Add a Meta Pixel to the web container for browser tracking. In the server container, create a Meta Conversions API tag for server-side tracking, and set it to fire when the data from the website arrives at the server. Create a "Meta Access Token" variable and instead of value enter the "YOUR_META_ACCESS_TOKEN_HERE" placeholder. My Meta Pixel ID is 1234567890000000.
Don't publish anything. When you're done, tell me: the container IDs, the Stape hosting URL, what you created, how the Meta Conversions API tag gets triggered, and anything you still need from me.
Tip:
You can go to your GTM and Stape accounts and watch how everything appears in real-time.
2. Replit takes a few minutes, then replies with a summary like this:
GTM-XXXXXXX) and server container ID.
Access tokens are sensitive information, and you should add this yourself.
1. Go to Google Tag Manager → your server container.

2. Click Variables → Meta Access Token.

3. Enter the Value that you copied earlier from the Meta Events Manager.

1. Now that the containers exist, ask Replit to connect the app to them and set up firing events. Here you'll need to ask to add a unique event ID. When you track the same conversion in two places, the Meta Pixel in the browser and the Facebook Conversions API on the server, Meta receives two events for one event. The event_id is how Meta knows they're the same action: when the browser event and the server event carry an identical ID, Meta merges them and counts as one conversion instead of two. This is called event deduplication, and without it any event will be overreported if deduplication is not configured numbers will inflate. For more information about deduplication you can read How to set up Facebook event deduplication in Google Tag Manager.
Add the Picket web GTM container to this app, then set up these two things:
1. Track page views. Record a page view when someone opens a page and when they move to another page within the app.
2. Track leads. When someone successfully submits the reservation form, record it as a "generate_lead" event. Tag it with the name "kayak_request", give each lead a unique ID, and include the person's email.
Send this data to both GA4 and Meta:
Set everything up but don't publish the GTM containers.
When passing personal data to ad platforms, check whether it's acceptable for your business and you have a legal basis and consent for it. You can include that data to raise Event Match Quality (EMQ). The best way to do it is to pass the values to the server container and let the Meta Conversions API tag hash them (SHA-256) before they reach Meta. The Meta Conversions API tag automatically hashes the applicable parameters.

2. On the top-right of the screen, click Publish to publish your app.
Setting up a custom domain is highly recommended to unlock the full potential of server-side tracking. When your tagging server operates on a custom subdomain like sst.yourdomain.com, browsers recognize its cookies as first-party data. While Safari's ITP restricts browser-script cookies to just 7 days, server cookies remain active far longer – ensuring returning visitors are recognized and your attribution windows remain complete. What's more, tracking requests blend in with your main traffic, keeping your conversions safe from ad blockers and privacy features.
Keep in mind that this step requires your Replit app to use a custom domain, as the default .replit.app address won't work here. Since the MCP server only manages the Stape configuration, you'll just need to add the required DNS records at your external domain provider.
Whenever you're ready to kick off the setup, send this prompt and follow along with the prompt response:
Using Stape connector, connect a custom subdomain.
1. In Google Tag Manager, go to your server container, and click Preview. Then, go to your web container, and click Preview as well. Enter the live site URL when asked. You'll get a new screen with the Tag Assistant.
2. In the Tag Assistant screen fill in the form and submit it. In web preview, the generate_lead event should appear, click on it to check whether GA4 and Meta tags have successfully fired.

3. In the server container preview, open the generate_lead event. Check the incoming request from the web container and the outgoing HTTP requests. Everything should have the 200 status.

4. Go to GA4 → Admin → Debug view.

5. You should see your events.

6. Go to Meta Events Manager → Datasets → select your dataset. You should see your events. It might take up to 30 minutes for events to appear, but you can test your events in the Test events tab right away.

7. Go back to Replit, and ask to publish the GTM containers:
Publish both GTM containers.
Tips:
Using the Stape connector, enable the Custom Loader, select 'Other' as the platform, enter web GTM container ID, and add the generated code to this project.
While Picket serves as an illustrative model, you can adapt these instructions to your own application by incorporating the following:
generate_lead with core business conversion events relevant to your goals, such as sign_up, begin_checkout, purchase, or demo bookings.Thanks to GTM and Stape working together, your Growth dashboard tracks every visit, while Meta captures every valuable lead – giving you full visibility into your conversions.
You shared your vision, the agent did the heavy lifting, and you verified the results before pushing to production. Connecting two MCP servers saved you hours of tedious GTM configuration, auto-generating containers, Stape hosting, GA4/Meta tags with just a few prompts.
As your application expands with new features – like a pricing page, checkout funnel, or additional lead forms – simply ask the agent to extend your tracking framework. When you're ready to boost performance even further, Stape power-ups such as Cookie Keeper and Custom Loader can extend cookie lifespans and minimize data loss from ad blockers.
Want to start on the server side?
Try for freeNov 23, 2026
Blog
Learn how to safely connect AI to Google Tag Manager with six key controls – from permission scoping to consent verification – before you publish live.
Aug 11, 2026
Comments