8000 GitHub - mehanahmed/gtmfake · GitHub
[go: up one dir, main page]

Skip to content
mehanahmedPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

GTM Setup Agent 🚀

Automated Google Tag Manager (GTM) Container Generator for eCommerce Tracking (GA4 & Meta Pixel) and Custom Event & Lead Generation Tracking (Button Clicks, Scroll Depth, Timer, Lead Forms, Phone & Email clicks).


🌐 Share Anywhere — Web App Included!

This project includes a 100% Client-Side Web Application (index.html) that requires zero backend servers or databases.

Ways to use and share:

  1. Open directly in browser: Double-click index.html to open in your browser offline.
  2. Deploy to GitHub Pages:
    • Push this repo to GitHub.
    • Go to Settings > Pages > Branch: main > Save.
    • Your tool will be live at https://<your-username>.github.io/<repo-name>/!
  3. Deploy to Vercel:
    • Import the GitHub repo; vercel.json selects the Next.js framework preset, so the Studio, Validator, and DataLayer routes are built and hosted from src/.
    • The standalone index.html copy is kept for offline use and GitHub Pages only (public/index.html is served as a static asset by Next).

📦 What It Configures Automatically

Module 1: eCommerce Tracking Suite (GA4 & Meta Pixel)

  • Variables (Strictly 24 User-Defined Variables):
    • Constants (2): Measurement Id, Facebook Pixel I'd
    • 1st Party Cookies (2): FBC COOKIY (_fbc), FBP COOKIY (_fbp)
    • Data Layer Variables (16, Version 2): DLV order_id, DLV value, DLV currency, DLV COPON Variable, DLV content_id, DLV-content_category, DLV_ content name, DLV EMAIL Variable, DLV PHONE Variable, DLV FIRST NAME Variable, DLV LAST NAME Variable, DLV CITY Variable, DLV POSTAL CODE Variable, DLV COUNTRY Variable, DLV items, DLV unique_event_id
    • Custom JavaScript Variables (4): CJ_Event Id (deduplication), CJ_Event_Time, CJ quantity Variable, CJ contents
  • Triggers (4 Custom Event Triggers):
    • View item Trigger (view_item)
    • add_to_cart Trigger (add_to_cart)
    • begin_checkout Trigger (begin_checkout)
    • purchase Trigger (purchase)
  • Tags (10 Production Tags):
    • 5 GA4 Tags: Google Tag (Config), GA4_view_item, GA4_AddToCart, GA4_begin_checkout, GA4_Purchase (with DataLayer pass-through & parameters).
    • 5 Meta Pixel Tags: Fb Page view, Fb ViewContent, Fb AddToCart, Fb InitiateCheckout, Fb Purchase (with Event ID deduplication and Advanced Matching).
    • Embedded Official Meta Template: Bundles official Meta Pixel template (templateId: "1") mapped to cvt_1_1.
  • Server-Side Routing, Currency & Content Type (Optional):
    • server_container_url configuration parameter on both the GA4 Configuration Tag and AW - Google Tag (enables server-side GTM routing).
    • Configurable currency / x-fb-cd-currency values for purchase and add_to_cart events (also exposed in the Studio UI).
    • Configurable content_type (product or product_group) applied to GA4 event parameters and Meta object properties (also exposed in the Studio UI).

Module 2: Custom Event & Lead Gen Interaction Suite

  • Triggers (6 Interaction Triggers):
    1. Scroll Depth - 25%, 50%, 100%: Vertical scroll percentage tracking.
    2. Timer - 10s, 30s, 60s Engagement: Active visitor engagement intervals.
    3. Click - Phone Number (tel): Detects and captures clicks on phone number links (tel:).
    4. Click - Email Link (mailto): Detects and captures clicks on email links (mailto:).
    5. Click - Button & Interactive Elements: All button and link click interactions (ID, Class, Text).
    6. Lead Form - Submission: Successful lead form submission capture.
  • Tags (8 Interaction Tags):
    • GA4 Tags (6): GA4_click_button, GA4_scroll_depth, GA4_time_engagement, GA4_click_phone, GA4_click_email, GA4_generate_lead.
    • Meta Pixel Tags (2): Fb Contact - Phone & Email Tag (Contact standard event), Fb Lead - Form Submit Tag (Lead standard event).
  • Built-in Variables Auto-Enabled:
    • Click ID, Click Classes, Click Text, Click URL, Click Element
    • Scroll Depth Threshold, Scroll Depth Units, Scroll Direction
    • Form ID, Form Classes, Form URL, Form Text

💻 CLI Usage

Generate container with all modules (eCommerce + Lead Gen):

node src/index.js --ga4 G-XXXXXXXXXX --pixel 123456789012345 --preset all --out gtm_container.json

Route hits through a server-side GTM container with a custom currency:

node src/index.js --ga4 G-XXXXXXXXXX --pixel 123456789012345 --server-url https://server.example.com --currency BDT --content-type product_group --out gtm_container.json

Generate container with eCommerce only (strictly 24 variables):

node src/index.js --ga4 G-XXXXXXXXXX --pixel 123456789012345 --preset ecom --out gtm_container.json

Generate container with Lead Gen / Interactions only:

node src/index.js --ga4 G-XXXXXXXXXX --pixel 123456789012345 --preset leads --out gtm_container.json

Run automated test suite:

npm.cmd test

📥 How to Import into Google Tag Manager

  1. Open Google Tag Manager.
  2. Select your Web Container and go to Admin.
  3. Under the Container column, click Import Container.
  4. Choose the generated gtm_container.json file.
  5. Under Choose workspace, select Existing (e.g. Default Workspace).
  6. Under Choose an import option, select Merge → Overwrite conflicting tags, triggers, and variables.
  7. Click Confirm.

🎉 All variables, triggers, and tags are now instantly live in your workspace!

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

0