- Home
- Skills
- APIs & Backend
- GA4 Event Tracking Spec Writer
Works with the AI Agents you already use
GA4 Event Tracking Spec Writer
Convert marketing tracking requests into technical GA4 dataLayer specs and GTM configurations.
$4.99
GA4 Event Tracking Spec Writer
Example session with this skill installed
Marketing Request: We need to track when users click the "Download Enterprise Report" button on the new landing page.
Element/Page Details: The button has the ID 'download-btn-ent' and is located on '/landing-pages/enterprise-strategy'. We need to know the user's industry if they are logged in.
- Read your context and instructions
- Compiled the ga4 event tracking
1. Tracking Overview
Track clicks on the "Download Enterprise Report" button (#download-btn-ent) on /landing-pages/enterprise-strategy. The business objective is to measure gated-content engagement on the enterprise landing page and segment it by the visitor's industry, so marketing can see which verticals are most interested in the report. Industry is captured only for logged-in users. For anonymous visitors the event still fires, with industry set to not_logged_in.
2. dataLayer Push (Developer Implementation)
Attach the push to the button's click handler. Read the industry from the authenticated user object at click time, not at page load, so the value is current.
window.dataLayer = window.dataLayer || [];
document.getElementById('download-btn-ent').addEventListener('click', function () {
// Replace `window.currentUser` with your app's actual auth/user object
var isLoggedIn = !!(window.currentUser && window.currentUser.id);
var industry = isLoggedIn && window.currentUser.industry
? String(window.currentUser.industry).toLowerCase()
: (isLoggedIn ? 'unknown' : 'not_logged_in');
window.dataLayer.push({
event: 'download_enterprise_report',
content_name: 'Enterprise Report',
content_type: 'report',
button_id: 'download-btn-ent',
page_path: '/landing-pages/enterprise-strategy',
login_status: isLoggedIn ? 'logged_in' : 'logged_out',
user_industry: industry
});
});
Implementation notes for developers:
- Do not push PII (name, email, user ID) in this event.
- Use a single, consistent lowercase taxonomy for
user_industryvalues (e.g.,finance,healthcare,retail). - If the button triggers a navigation or file download, make sure the push happens before navigation. This is normally fine with a click listener, but verify in testing.
- If the button is rendered dynamically (SPA or lazy-loaded), use event delegation, e.g.
document.addEventListener('click', e => { if (e.target.closest('#download-btn-ent')) { ... } }).
3. Google Tag Manager (GTM) Configuration
- Trigger Type: Custom Event
- Event Name:
download_enterprise_report(exact match, case-sensitive; do not use regex) - Firing Conditions: Fire on "Some Custom Events" with the following condition:
Page Pathequals/landing-pages/enterprise-strategy
Data Layer Variables to create (Version 2):
| GTM Variable Name | Data Layer Variable Name |
|---|---|
| DLV - content_name | content_name |
| DLV - content_type | content_type |
| DLV - button_id | button_id |
| DLV - login_status | login_status |
| DLV - user_industry | user_industry |
GA4 Event Tag:
- Tag Type: Google Analytics: GA4 Event
- Configuration/Measurement ID: your GA4 Measurement ID (or the GA4 Configuration tag variable)
- Event Name:
download_enterprise_report
Event Parameters: map each parameter name to its DLV variable above (content_name, content_type, button_id, login_status, user_industry)
- Trigger: the Custom Event trigger defined above
Fallback (if developer dataLayer work is delayed): Use a Click trigger ("All Elements" → "Some Clicks") with Click ID equals download-btn-ent AND Page Path equals /landing-pages/enterprise-strategy. Note that this fallback cannot access user_industry unless the industry is already exposed in the dataLayer or a first-party cookie, so the dataLayer push is the recommended approach.
4. GA4 Custom Dimensions Mapping
Register these in
GA4 Admin → Custom definitions → Create custom dimension. Event-scoped dimensions are needed for all parameters except where noted.
| Parameter Name | Dimension Name | Scope | Description |
|---|---|---|---|
user_industry | User Industry | Event | Industry of the logged-in user at time of click. Values: lowercase industry slug, unknown (logged in but not set), or not_logged_in. |
login_status | Login Status | Event | Whether the user was authenticated at time of click (logged_in / logged_out). |
content_name | Content Name | Event | Name of the asset being downloaded (Enterprise Report). Useful if more reports are added later. |
content_type | Content Type | Event | Type of content (report). |
button_id | Button ID | Event | HTML ID of the clicked element (download-btn-ent). |
Additional recommendations:
- If
user_industryshould also describe the user across all events (not just this click), additionally set it as a
User Property (user_industry, scope: User) via a set on the GA4 Configuration tag or a user-properties field on the Event tag, then register it as a User-scoped dimension.
- Consider marking
download_enterprise_reportas a
Key Event in GA4 (Admin → Events) if it represents a conversion.
page_pathis collected automatically by GA4 aspage_location, so no custom dimension is needed. It is included in the push for use as a GTM trigger condition.- GA4 standard properties allow up to 50 event-scoped custom dimensions, so check your quota before registering.
- Custom dimensions populate in reports only for data collected after registration (typically 24-48 hours).
QA checklist: Verify in GTM Preview mode that the download_enterprise_report event appears in the Data Layer tab with correct values for both a logged-in and an anonymous session. Then confirm in GA4 DebugView that all five parameters arrive on the event.
Connects securely to your tools. The creator never sees your data.
About this skill
Marketing requests for web tracking often lack the technical detail developers need to actually write the code. This skill bridges that gap by converting high-level tracking goals into structured Google Tag Manager (GTM) and GA4 implementation specifications.
What it does
- Generates dataLayer snippets by providing exact JavaScript code blocks for frontend developers to implement.
- Defines GTM triggers including specific trigger types, event names, and firing conditions like CSS selectors or URL matches.
- Maps GA4 dimensions using structured tables to align event parameters with custom dimension names and scopes.
- Standardizes naming conventions to ensure event data is clean and consistent across the tracking implementation.
How it works
- Provide the marketing request detailing what needs to be tracked.
- Include element or page details like CSS classes, IDs, or specific URLs.
- The skill generates a technical overview, code blocks, and GTM configuration steps.
Frameworks & tools
This tool focuses on Google Tag Manager (GTM) and Google Analytics 4 (GA4) implementation via JavaScript dataLayer.push events.
Why this beats prompting it yourself
Generic prompts often miss the specific GA4 parameter scoping or provide invalid dataLayer syntax. This skill enforces a developer-ready structure that includes both the implementation code and the platform configuration details in one pass.
Use cases
- Generating tracking code for a new lead generation form submission.
- Creating a spec for e-commerce "Add to Cart" events on custom buttons.
- Documenting scroll depth or video engagement tracking requirements.
- Auditing and formalizing legacy tracking into GA4-compatible specs.
Known limitations
Does not provide server-side GTM configurations or non-JavaScript tracking methods. Implementation requires manual setup of dimensions in the GA4 interface.
Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for APIs & Backend.
Requires manual creation of custom dimensions in the GA4 UI. Limited to JavaScript dataLayer implementations for web.
How to use
- 1
Connect your agent to the Agensi MCP
Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup
- 2
Sign in to Agensi
Your agent shows a sign-in link. Sign in and click Allow.
- 3
Ask for what you need
Your agent loads this skill and uses it on your task. It always asks before buying a skill.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill goes through the trust checks below.
Security scanned
Checked by our 8-point scan before listing
Fresh listing
Recently published to Agensi
Money-back guarantee
Doesn't do what its page promises? You get your money back.
Trust & safety
Security scan
Security scan passed 19 days ago