7 min read
Analytics Architecture and Setup (GTM, GA4, Pixels)

1. Hierarchy and Terminology

Google Tag Manager (GTM)

  • GTM Account: Usually one per company/client.
  • Container: This is your “website” or “app”. One website = one container. This is the code you insert into all pages of your site (in <head> and <body>).
  • Tag: A piece of code or a pixel (e.g., Google Analytics code, Facebook Pixel, TikTok Pixel) that performs an action (transmits data).
  • Trigger: A condition under which a Tag fires. (e.g., “User visited any page” (All Pages) or “User visited the /success page”).
  • Variable: Stores data that can be used in tags and triggers (e.g., current page URL, transaction ID).

Google Analytics 4 (GA4)

  • GA Account: One per company/client.
  • Property: Usually corresponds to one website or app. All data is collected within a property.
  • Data Stream: The source of data for the property. A website will have one Web Data Stream with its own identifier (Measurement ID like G-XXXXXXXXXX).

How are they connected?

You do not place Google Analytics code or pixels directly onto the website (in the source code). You place only the GTM Container code on the site. Then, inside GTM (via a user-friendly browser interface), you create Configuration Tags for Google Analytics, Facebook, TikTok, etc., and specify the necessary IDs. This way, GTM itself loads the analytics and necessary scripts onto the site according to your rules (triggers). This allows you to add new metrics without touching the site’s code.


2. Visual Structure (Diagram)

graph TD
    Site[Your Website] -->|Only this code in source| GTM_C[GTM Container]
    
    subgraph Google Tag Manager
        GTM_C --> TriggerALL[Trigger: All Pages]
        GTM_C --> TriggerSuccess[Trigger: Page URL contains /success]
        
        TriggerALL -.->|Fires| TagGA4[Tag: GA4 Configuration]
        TriggerALL -.->|Fires| TagFBPx[Tag: Facebook Pixel - Base]
        TriggerALL -.->|Fires| TagTT[Tag: TikTok Pixel - Base]
        
        TriggerSuccess -.->|Fires| TagGA4Conv[Tag: GA4 Event - generate_lead]
        TriggerSuccess -.->|Fires| TagFBConv[Tag: Facebook Pixel - Lead]
        TriggerSuccess -.->|Fires| TagTTConv[Tag: TikTok Pixel - SubmitForm]
    end

    TagGA4 -->|Sends base views| GA4_P[GA4 Property]
    TagGA4Conv -->|Sends conversion| GA4_P
    
    TagFBPx -->|Sends views| FB_BM[Meta Business Manager]
    TagFBConv -->|Sends leads| FB_BM

3. Configuration Logic: Base Traffic vs. Conversions

Yes, your logic in the question is absolutely correct. For each advertising platform (Meta, TikTok, Pinterest, etc.), you need to set up two levels of tags in GTM:

  1. Base Pixel (to track all visitors):

    • Tag: The platform’s main pixel code (e.g., Facebook Pixel Base Code).
    • Trigger: All Pages (Fires on all pages).
    • Goal: Understand who visited the site, and build audiences for retargeting.
  2. Conversion Tag (or Event - for optimization):

    • Tag: A small snippet of code for a specific event (e.g., the Lead event from Facebook Pixel). It doesn’t replace the base pixel; it works alongside it!
    • Trigger: Success Page (You create your own trigger, e.g., type Page View -> condition Page URL contains /success).
    • Goal: Signal the advertising platform: “This user didn’t just visit; they submitted a request!”. This is critical for campaigns with a “Conversions” goal.

You don’t need to create a “new trigger for every tag”. You create one “Success Page” trigger and attach all conversion tags (GA4 Lead, Facebook Lead, TikTok Lead, Pinterest Checkout, etc.) to it.


4. Scenario: Quick Launch (Automating the Process)

When you have a new client or a new project, follow this template:

Step 1: Create Infrastructure (One-time)

  1. In the GTM account, create a new Container (Web type). Name it “Client X Website”.
  2. In the GA account, create a new Property. Name it “Client X Website”. Create a Web Data Stream there and copy the Measurement ID (G-...).
  3. In advertising accounts (Meta BM, TikTok Ads), create Pixels for this site and copy their IDs and base codes.

Step 2: Install on Website (One-time)

  1. Take the Container code from GTM and give it to the developer (or insert it yourself) into the <head> and <body> of all site pages. That’s it; you don’t need to touch the site’s code again.

Step 3: “All Pages” Setup (Base Tracking)

  1. Google Analytics 4:
    • In GTM -> Create Tag -> Google Tag (or GA4 Configuration). Paste the Measurement ID. Trigger: All Pages. Save.
  2. Other Pixels (Meta, TikTok):
    • In GTM -> Create Tag -> Custom HTML. Paste the multi-line base pixel code provided by Facebook. Trigger: All Pages. Save.

Step 4: “Conversions” Setup (Success Actions)

  1. Create Trigger (Only once):
    • In GTM -> Triggers -> New. Type: Page View. Condition: Some Page Views. Rule: Page URL contains success (or thank-you, depending on your site’s URL after submission). Name it Trig - Success Page.
  2. Create Events:
    • GA4 Event: Tag -> GA4 Event. ID: Same. Event Name: generate_lead. Trigger: Trig - Success Page.
    • Meta Event: Tag -> Custom HTML. Code: <script>fbq('track', 'Lead');</script>. Important: In Advanced Settings (Advanced Tag Sequencing), specify that this tag should fire STRICTLY AFTER the “FB Base Pixel” tag (Fire a tag before…). Trigger: Trig - Success Page.
    • Repeat the same for TikTok, X, Pinterest, using their event snippets and the same Trig - Success Page trigger.

Step 5: Publish

  • Click the large blue Submit (Publish) button in the top right corner of GTM. Until you do this, none of the tags will work on the site.

5. UTM Template Strategy (Must Use!)

Even if traffic is just for “video views” on the site or “social reach” — UTM tags are always needed. Only with them in GA4 can you distinguish Facebook traffic from TikTok traffic, and paid ads from free posts.

Anatomy of a UTM link: https://your-site.com/?utm_source=SOURCE&utm_medium=TRAFFIC_TYPE&utm_campaign=CAMPAIGN_NAME

  • utm_source – Platform (google, facebook, instagram, tiktok, pinterest, linkedin, nextdoor, x_twitter).
  • utm_medium – Format/Payment. Use cpc for paid ads and social for free organic posts.
  • utm_campaign – Name (e.g., black_friday, promo_video_2026).

Platform Cheat Sheet

1. Google Ads (Search, YouTube)

You don’t need to write anything by hand! Just go to the Google Ads account settings and enable “Auto-tagging”. Google will do everything itself and link with GA4 perfectly.

2. Paid Social Media Ads (Meta, TikTok, LinkedIn, Pinterest)

Since these are “foreign” platforms to Google, tags are mandatory.

  • Facebook Ads (Traffic/Conversions): ?utm_source=facebook&utm_medium=cpc&utm_campaign=retargeting_usa&utm_content=video_creative_1
  • TikTok Ads: ?utm_source=tiktok&utm_medium=cpc&utm_campaign=conversions_gen_z
  • LinkedIn Ads (good for B2B): ?utm_source=linkedin&utm_medium=cpc&utm_campaign=lead_gen_ceos

3. Organic Posts (Free Traffic)

When you simply publish posts, Reels, or tweets on your pages.

  • Instagram (bio link): ?utm_source=instagram&utm_medium=social&utm_campaign=bio_link
  • Threads (discussion link): ?utm_source=threads&utm_medium=social&utm_campaign=thread_discussion_45
  • WhatsApp (client broadcast): ?utm_source=whatsapp&utm_medium=messenger&utm_campaign=direct_promo_summer
  • Pinterest Pin: ?utm_source=pinterest&utm_medium=social&utm_campaign=new_collection_board
  • Twitter/X: ?utm_source=x_twitter&utm_medium=social&utm_campaign=daily_news_tweet
  • Nextdoor (local neighbor broadcast): ?utm_source=nextdoor&utm_medium=social_local&utm_campaign=neighborhood_services

Lifehack for UTM Automation

Never write them manually. Use the Google Campaign URL Builder tool (search for it online) or create a simple spreadsheet in Excel/Google Sheets where you type the link, select the social network from a dropdown, and it generates the long link for your ads.