Skip to content

Conversation

@igorantun
Copy link
Contributor

@igorantun igorantun commented Jan 8, 2026

Summary

  • Add AdCP-to-GAM macro mapping utilities for tracking URLs in src/adapters/gam/utils/macros.py
  • Map AdCP universal macros ({CACHEBUSTER}, {GDPR}, {AXEM}, etc.) to their GAM equivalents
  • Support multiple GAM macro formats: %%MACRO%% (standard), ${MACRO} (GDPR/TCF), %macro! (expand), %{MACRO} (prebid)
  • Fix impression tracking to use correct GAM fields per creative type:
    • ThirdPartyCreative, ImageRedirectCreative, CustomCreativethirdPartyImpressionTrackingUrls
    • VideoRedirectCreativetrackingUrls with CREATIVE_VIEW event
  • Add tracker_redirect url_type support in creative_helpers.py for click tracking
  • Click tracker URL replaces destinationUrl, with {REDIRECTION_URL} substituted with original landing page (URL-encoded)
  • Bugfix for issue: Bug: Media Buy Adapter Creation Failure #954

Macro Mapping Highlights

AdCP GAM Notes
{CACHEBUSTER} %%CACHEBUSTER%%
{GDPR} ${GDPR}
{CLICK_URL} %%CLICK_URL_ESC%% For snippets
{PLACEMENT_ID} %epid! Expand macro
{AXEM} %{AXEM} Prebid format
{REDIRECTION_URL} (original destination) URL-encoded
{GDPR_CONSENT} passthrough Already filled
{GPP_STRING} passthrough Already filled

Tracking Flow

  • Impression tracking: URLs from tracker_pixel/tracker_script assets added to thirdPartyImpressionTrackingUrls
  • Click tracking: URLs from tracker_redirect assets replace destinationUrl, redirecting: GAM → click tracker → landing page

Test plan

  • Unit tests for macro mapping and substitution (53 tests in tests/unit/test_gam_macros.py)
  • Unit tests for creative type field mapping
  • Unit tests for click tracking with REDIRECTION_URL
  • Integration tests for tracking URL flow
  • Manual verification with GAM sandbox environment

🤖 Generated with Claude Code

Add AdCP-to-GAM macro mapping utilities for tracking URLs:
- Map AdCP universal macros ({CACHEBUSTER}, {GDPR}, etc.) to GAM equivalents
- Support multiple GAM macro formats (%%MACRO%%, ${MACRO}, %macro!)
- Passthrough unmapped macros to preserve third-party tracking
- Fix tracking URL field path in creatives manager

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@github-actions
Copy link
Contributor

github-actions bot commented Jan 8, 2026

All contributors have agreed to the IPR Policy. Thank you!
Posted by the CLA Assistant Lite bot.

@igorantun
Copy link
Contributor Author

I have read the IPR Policy

@igorantun igorantun marked this pull request as draft January 8, 2026 21:27
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@igorantun igorantun force-pushed the igorantun/tracking-pixels branch from 3784539 to 029a784 Compare January 12, 2026 17:26
@igorantun igorantun marked this pull request as ready for review January 12, 2026 17:41
Copy link
Contributor

@bokelley bokelley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make sure click urls work with GAM click tracking, that imp trackers fire properly, and that axem is filled out. use wonderstruck

igorantun and others added 2 commits January 14, 2026 01:07
- Fix impression tracking for ImageRedirectCreative and CustomCreative
  to use thirdPartyImpressionTrackingUrls field
- Fix VideoRedirectCreative to use trackingUrls with CREATIVE_VIEW event
- Map {AXEM} to %{AXEM} (prebid macro format)
- Remove click tracking URL handling - clicks should be tracked via
  macros in the creative snippet per GAM documentation
- Add unit tests for creative type field mapping

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Click tracking works via redirection: GAM → click tracker → landing page
The click tracker URL is set as destinationUrl, which redirects to final
landing page after tracking the click.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@igorantun igorantun force-pushed the igorantun/tracking-pixels branch from f807948 to c3eeab7 Compare January 15, 2026 19:04
igorantun and others added 4 commits January 16, 2026 13:43
- Add tracker_redirect url_type handling in creative_helpers.py
- Click tracker URL now always replaces destinationUrl
- {REDIRECTION_URL} macro is replaced with original destination (URL-encoded)
- Flow: GAM → click tracker → landing page

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…RL macro

- Change {REDIRECTION_URL} to {REDIRECT_URL} in GAM creatives.py
- Add role name fallback for impression_tracker (impression_tracker, tracker_pixel, pixel)
- Add role name fallback for click_tracker (click_tracker, tracker_redirect, redirect_tracker)
- Update tests to use REDIRECT_URL macro name

This makes url_type optional for trackers, matching the existing click_url behavior.
- Click tracker without {REDIRECT_URL} macro is now ignored when landing page exists
  (prevents losing landing page URL)
- Add warning for click tracker missing {REDIRECT_URL} macro
- Add warning for click tracker with {REDIRECT_URL} but no landing page
- Add warning when multiple click trackers provided (only first is used)
- Fix: Native creatives now call _add_tracking_urls_to_creative
- Fix: TemplateCreative (native) now handled in tracking URL logic
- Update tests to reflect new behavior
…ontext

The adapters were passing tenant_gemini_key as the 5th positional argument,
but build_order_name_context() has tenant_ai_config as the 5th parameter.
This caused the string API key to be treated as an AI config object,
resulting in: 'str' object has no attribute 'api_key'

Changes:
- src/adapters/google_ad_manager.py: Use keyword arg tenant_gemini_key=
- src/adapters/mock_ad_server.py: Use keyword arg tenant_gemini_key=
- src/adapters/gam/managers/workflow.py: Use keyword arg tenant_gemini_key=
- tests/unit/test_naming_parameter_bug.py: Add test documenting the bug
- tests/unit/conftest.py: Fix mock to prevent MagicMock type leakage
- tests/unit/test_gam_workflow_packages.py: Fix mock configuration
@BaiyuScope3
Copy link
Collaborator

BaiyuScope3 commented Jan 16, 2026

The Axem fires properly on the wonderstruck (integrated with our RTDP), tested manually (this is only to test axem macro, not the full macro list, the real E2E test will be done with wonderstruck after this PR merged )
image

@igorantun igorantun requested a review from bokelley January 16, 2026 20:42
@BaiyuScope3 BaiyuScope3 requested a review from youbek January 16, 2026 20:43
Fixes mypy errors:
- src/core/helpers/creative_helpers.py:360 - Item 'str' of 'list[str] | str' has no attribute 'append'
- src/core/helpers/creative_helpers.py:369 - Item 'str' of 'list[str] | str' has no attribute 'append'

Uses the same pattern already established on lines 350-352.
@BaiyuScope3 BaiyuScope3 merged commit a3dd2d1 into adcontextprotocol:main Jan 16, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants