generateDataLayerEvent
Generate ES5-compatible event tracking code for Adobe Target conversion elements. Supports multiple tag managers and configurable firing conditions to prevent duplicate conversions.
Instructions
Generate ES5-compatible event tracking code for Adobe Target activity conversions. Supports multiple tag managers with configurable event structures and firing conditions.
SUPPORTED TAG MANAGERS:
gtm: Google Tag Manager (dataLayer.push)
adobeLaunch: Adobe Experience Platform Tags (_satellite.track)
tealium: Tealium iQ (utag.link)
segment: Segment Analytics (analytics.track)
customDataLayer: Custom dataLayer implementation
USAGE: When creating or modifying Target experiences with conversion elements (buttons, links, forms), use this tool to generate click tracking code.
WORKFLOW:
User creates an experience with a button/link/conversion element
LLM identifies the conversion element selector
LLM asks: "What should I name this activity?" (if not already provided)
LLM asks: "What experience name should I use?" (e.g., "Experience A", "Control", "Variant B")
TAG MANAGER SELECTION:
If full-page extraction was done earlier, check context for tagManagers.summary.recommendedForTracking
If tag manager was auto-detected, use that (inform user: "I detected {name} on the page")
If NOT detected or no full-page extraction in context, ask: "Which tag manager are you using?" (default: adobeLaunch)
LLM MUST ASK: "When should this conversion event fire?" and present these options:
1. Every time (no limit) - DEFAULT - Track every interaction 2. Once per session - Track only once per session (prevents duplicate conversions) 3. Once per page - Track only once per page load 4. Once ever - Track only once, stored permanently 5. Throttle - Limit frequency (e.g., max once per second) 6. Debounce - Wait for user to stop interacting
Default is "always" (every time). User can override if needed.
LLM calls this tool with selector, activity_name, experience_name, tag_manager (auto-detected or selected), and firing_condition
Tool returns ES5-compatible click event listener code with firing condition logic
LLM includes this code in the activity modifications
FIRING CONDITIONS:
always: No limit, fires every time - DEFAULT
once_per_session: Fires once per session (uses sessionStorage) - For preventing duplicate conversions
once_per_page: Fires once per page load (uses flag)
once_ever: Fires once ever (uses localStorage)
throttle: Limits frequency (requires interval parameter in ms)
debounce: Waits for user to stop (requires delay parameter in ms)
IMPORTANT:
ALWAYS ask about firing conditions - don't assume
Default is "always" (fires every time) - user can override if needed
Attach to ALL conversion elements (buttons, CTAs, forms, etc.)
Attach to the most specific selector possible
Attach to negative user actions aswell, like ignoring a popup or closing a modal
activity_name should match the Target activity name
experience_name should be descriptive (e.g., "Control", "Variant A", "Green Button Test")
Generated code is ES5-compatible (no template literals, arrow functions, const/let)
Code includes defensive check for element and tag manager object existence
NO polling/setInterval - Target fires after DOM ready, so elements should already exist
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| selector | Yes | CSS selector for the conversion element (button, link, etc.) - e.g., "#cta-button", ".at-signup-btn" | |
| event_name | No | Custom event name (optional). If not provided, uses tag manager default (e.g., "target_conversion" for GTM, "target-conversion" for Adobe Launch) | |
| event_type | No | Type of DOM event to track (default: "click"). Can be "click", "submit", "change", etc. | |
| tag_manager | No | Tag manager to use: "adobeLaunch" (Adobe Launch), "gtm" (Google Tag Manager), "tealium" (Tealium iQ), "segment" (Segment), or "customDataLayer" (Custom implementation). Default: "adobeLaunch" | |
| activity_name | Yes | The name of the Adobe Target activity (should match activity name in Target) | |
| firing_params | No | Parameters for throttle/debounce conditions. For throttle: { interval: 1000 }. For debounce: { delay: 500 }. Values in milliseconds. | |
| experience_name | Yes | The experience name/variant (e.g., "Experience A", "Control", "Variant B", "Green Button") | |
| firing_condition | No | When should the event fire? Options: "always" (every time - DEFAULT), "once_per_session" (prevents duplicate conversions), "once_per_page", "once_ever", "throttle", "debounce". Default: "always" | |
| include_comments | No | Include explanatory comments in the generated code (default: true) |