Amazon Ads Advanced Tools Documentation

repository·main·Indexed 41 days ago

https://github.com/amzn/ads-advanced-tools-docs

Supplementary resources for developers using Amazon Ads advanced tools, including the Amazon Ads API and bulk operations. Provides Postman collections for the Amazon Ads API and Unified API, CloudFormation templates for Amazon Marketing Stream SQS and Firehose infrastructure, and implementation guides for the Amazon Ads Events API (v1) and Google Tag Manager (GTM) server-side templates.

Tokens
59.6K
Snippets
107
Records
201
Agent score
51%

What's inside Amazon Ads Advanced Tools

  1. Overview of Amazon Events API GTM Server-Side Templates

    main

    The Amazon Events API Google Tag Manager (GTM) server-side template collection enables advertisers to implement Amazon Events API (Conversions API v2) within a GTM server container. This solution moves conversion tracking from the user's browser to a secure server environment, bypassing client-side issues like ad blockers, browser privacy settings, and iOS tracking limitations.

    Core Benefits

    • Reliability: Direct server-to-server integration with Amazon Events API endpoints ensures data delivery is not blocked by client-side scripts.
    • Data Control: Allows for validation, normalization, and enrichment of conversion data in a controlled environment before transmission.
    • Privacy Compliance: Built-in support for TCF v2.0, GPP, and Amazon Consent frameworks.

    Supported Event Sources

    Data can flow into the GTM server container from:

    • Websites (via client-side tags)
    • Mobile apps
    • Server/backend systems (via Measurement Protocol)
  2. Compare Legacy DSP and Unified DSP Architectures

    main

    When migrating to the Unified API, note the following architectural shifts:

    AspectLegacy DSPUnified DSP
    Endpoint pattern/dsp/v1/{resource}/adsApi/v1/{action}/{resource}
    HTTP methodsMixed (POST, PATCH, etc.)All POST
    adProduct fieldNot required (implicit)Required: "AMAZON_DSP"
    State valuesACTIVE / INACTIVEENABLED / PAUSED / ARCHIVED
    Campaign creationCan create as ACTIVEMust create as PAUSED, then update to ENABLED
    Response structure{requestId, success:[], error:[]}{success:[], error:[]} (no requestId at top level)

    Important Lifecycle Note: You cannot create a campaign or ad group in an active state. You must create them with state: "PAUSED" and then perform a subsequent update to set the state to "ENABLED" to start delivery.

  3. Map Ad Type Creation to Unified API Creative Fields

    main

    In the Unified API, instead of using different endpoints for different ad types, you use the single endpoint POST /adsApi/v1/create/ads. The specific ad type is determined by the corresponding field within creative.componentCreative in your request body.

    | v4 Endpoint | Unified API Creative Field |
    |-------------|------------------------------|
    | `/sb/v4/ads/autoCollection` | `creative.componentCreative.autoCollectionSettings` |
    | `/sb/v4/ads/manualCollection` | `creative.componentCreative.manualCollectionSettings` |
    | `/sb/v4/ads/productCollection` | `creative.componentCreative.productCollectionSettings` |
    | `/sb/v4/ads/storeSpotlight` | `creative.componentCreative.storeSpotlightSettings` |
    | `/sb/v4/ads/video` | `creative.componentCreative.productVideoSettings` |
    | `/sb/v4/ads/brandVideo` | `creative.componentCreative.productVideoSettings` (with STORE landing page) |
  4. Distinguish between ASIN exact and expanded targeting

    main

    To distinguish between ASIN exact and expanded targeting in the Unified API, use the matchType within the productTarget object:

    • ASIN exact (精准): targetType: "PRODUCT" + productTarget.matchType: "PRODUCT_EXACT" (corresponds to SP v3 ASIN_SAME_AS).
    • ASIN expanded (扩展): targetType: "PRODUCT" + productTarget.matchType: "PRODUCT_SIMILAR" (corresponds to SP v3 ASIN_EXPANDED_FROM).
    • Category targeting: targetType: "PRODUCT_CATEGORY".
  5. Components of the Amazon Events API GTM Solution

    main

    The solution consists of three specific GTM templates that work in orchestration to handle authentication, formatting, and delivery:

    1. Amazon Events API Tag Template (Amazon_Events_API_Tag_Template.tpl): The primary tag that sends conversion events to Amazon's Events Manager Platform. It manages OAuth authentication, data normalization, PII hashing (SHA-256), consent processing, and event delivery.
    2. Amazon CAPI Auth Variable (Amazon_CAPI_Auth_Variable.tpl): A variable template that manages the OAuth lifecycle with the Amazon Ads API. It handles token generation, caching for 55 minutes (with a 5-minute buffer), and automatic refreshing.
    3. Amazon CAPI Timestamp Variable (Amazon_CAPI_Timestamp_Variable.tpl): A utility variable that converts epoch milliseconds into the ISO-8601 format required by the Amazon Events API. This is necessary because GTM's sandboxed JavaScript environment lacks a standard Date object.
  6. Understand the Amazon DSP Creative Lifecycle

    main

    To successfully deploy DSP creatives via the Unified API (/adsApi/v1/), you must follow a specific sequence of operations. Because ads are linked to ad groups via associations, you cannot simply create an ad and expect it to run; you must create the structural hierarchy first.

    The Complete Lifecycle:

    1. Create Campaign (set to PAUSED)
    2. Create Ad Group (set to PAUSED)
    3. Create Ad (this is where the creative content/settings reside)
    4. Create Ad Association (this links the specific adId to an adGroupId)
    5. Update Ad Group to ENABLED
    6. Update Campaign to ENABLED

    Key Concepts:

    • Ad: Represents the creative content and metadata. There is no separate 'creative' entity; the settings are nested within the Ad object.
    • Ad Association: The link between an Ad and an Ad Group. This object allows you to specify weight and schedule. One ad can be linked to multiple ad groups using multiple associations.
    • State Management: Ad associations have a state (ENABLED/PAUSED), whereas the Ad itself does not have a state property in the same way.
  7. Map SP v3 targeting types to Unified API targetTypes

    main

    When migrating targeting, map your SP v3 target types to the following Unified API targetType values:

    SP v3 Target TypeUnified API targetTypeUnified API targetDetails
    ASIN targetingPRODUCTproductTarget: { product: { productId }, productIdType: "ASIN", matchType: "PRODUCT_EXACT" }
    Category targetingPRODUCT_CATEGORYproductCategoryTarget: { productCategoryRefinement: {...} }
    Auto targetingTHEMEthemeTarget: { matchType: "..." }

    Note on Product ID Types: The Unified API supports both ASIN and SKU via the productIdType field.

  8. Understand the Sponsored Brands Collections (SBC) hierarchy

    main

    The SBC ad format follows a specific hierarchy. A Campaign must be created first, followed by an Ad Group, which contains Ads and Targets.

    Hierarchy Structure:

    • Campaign (adProduct: SPONSORED_BRANDS, costType: CPC)
      • Ad Group
        • Ad (Uses either autoCollectionSettings or manualCollectionSettings)
        • Targets (Can be keyword, product, productCategory, or theme)
    Campaign (costType: CPC, adProduct: SPONSORED_BRANDS)
      └── Ad Group
           ├── Ad (creative: autoCollectionSettings OR manualCollectionSettings)
           └── Targets (keyword, product, productCategory, theme)
  9. Handle Multi-Status (207) Responses

    main

    All create, update, and delete endpoints in the Unified API return a Multi-Status response pattern. This structure separates successful operations from errors, allowing for partial success in batch requests. You must check both the success and error arrays in the JSON response to determine the outcome of each item in your request.

    {
      "success": [
        { "index": 0, "campaign": { "campaignId": "123456789", ... } }
      ],
      "error": [
        { "index": 1, "errors": [{ "code": "FIELD_VALUE_IS_INVALID", "message": "..." }] }
      ]
    }
  10. How the Migration Assistant Agent works

    main

    The ads-api-migration-assistant agent uses a two-layer knowledge system to answer developer queries:

    1. Primary Layer (SKILL.md files): The agent first loads the specific skill files as context. These contain high-level migration guides, field mappings, and code examples.
    2. Fallback Layer (api-specs/*.json): If the skill files do not contain enough detail, the agent automatically searches the full OpenAPI schemas (located in the api-specs/ directory) to find precise field types, enum values, or schema details.

    This allows the agent to provide both strategic migration advice and precise technical implementation details.