AMP environment - Technical Requirements

Pubstack Node is compatible with AMP (Accelerated Mobile Pages) environments through the use of the AMP Real Time Config (RTC) protocol. This integration enables server-side header bidding on AMP page

circle-info

Prerequisites

  • Your AMP page must include a CMP compliant with TCF v2.2.

  • The Pubstack vendor (ID 1408) must be included in the list of allowed vendors.

  • Your ad units must be configured in Pubstack Node.

1

Import the AMP component

The amp-ad component is required to display ads on your AMP page. Include this script once per page in the <head> section:

<script
  async
  custom-element="amp-ad"
  src="https://cdn.ampproject.org/v0/amp-ad-0.1.js"
></script>
2

This iframe enables user ID synchronization between Prebid Server and demand partners. Include it once per page:

<amp-iframe
  width="1"
  height="1"
  title="User Sync"
  sandbox="allow-scripts allow-same-origin"
  frameborder="0"
  src="https://acdn.adnxs.com/prebid/amp/user-sync/load-cookie-with-consent.html?endpoint=https%3A%2F%2Fprebid-server.pbstck.com%2Fcookie_sync&max_sync_count=8&source=amp&bidders=pubstack&args=account:00000000-0000-0000-0000-000000000000">
  <amp-img
    layout="fill"
    src="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=="
    placeholder
  ></amp-img>
</amp-iframe>
circle-info

Account-specific code: This snippet contains your unique Pubstack Account ID. You can find the ready-to-use code for your account in the Pubstack interface: Media & stacks → [Select your media] → Connect to Pubstack

3

Tag amp-ad Configuration

The call to Pubstack Prebid Server is made through the rtc-config attribute. This configuration triggers the header bidding auction before the ad is requested from GAM. Here is a standard example:

<amp-ad
  width="300"
  height="250"
  type="doubleclick"
  data-slot="/NETWORK_ID/ad-unit-path"
  rtc-config='{
    "urls": [
      "https://prebid-server.pbstck.com/openrtb2/amp?tag_id=PUBSTACK_ADUNIT_NAME&w=ATTR(width)&h=ATTR(height)&slot=ATTR(data-slot)&curl=CANONICAL_URL&timeout=TIMEOUT&account_id=PUBSTACK_SITE_ID&gdpr_applies=CONSENT_METADATA(gdprApplies)&consent_type=CONSENT_METADATA(consentStringType)"
    ],
    "timeoutMillis": 800
  }'
></amp-ad>
circle-exclamation
circle-info

Account-specific code: Your Pubstack Account ID and ad unit names are available in the Pubstack interface: Media & stacks → [Select your media] → Connect to Pubstack

RTC-Config Parameters Reference

Query param
Designation
Description

account_id

siteId (Pubstack)

Unique Pubstack site identifier. Links the AMP request to your account and Node environment.

tag_id

ad unit name (Pubstack)

Name of the ad unit configured in Pubstack.

w

ATTR(width)

Ad placement width defined in the AMP tag.

h

ATTR(height)

Ad placement height defined in the AMP tag.

ms

ATTR(data-multi-size)

List of alternative sizes (e.g., 300x250,320x100) for multi-size bidding.

slot

ATTR(data-slot)

Full GAM slot identifier.

targeting

TGT

Additional targeting parameters (provided as JSON in <amp-ad>).

curl

CANONICAL_URL

Canonical URL of the AMP page, used for bidding context.

timeout

TIMEOUT

Maximum waiting time (ms). Recommended: 1000.

adc

ADCID

AMP Device ID – anonymous identifier used for tracking and deduplication.

purl

HREF

Full URL of the AMP page.

gdpr_consent

CONSENT_STRING

Full TCF v2.2 consent string from the AMP CMP.

consent_type

CONSENT_METADATA(consentStringType)

Type of consent string (tcfv2, usprivacy, etc.).

gdpr_applies

CONSENT_METADATA(gdprApplies)

Indicates whether GDPR applies (true/false).

addtl_consent

GAM Additional Consent

Additional list of authorized vendors used by Google Ad Manager under TCF.

debug

Enables debug mode to trace RTC requests (true/false). Only for testing environments.

Full Example

This example demonstrates a complete implementation with multi-size support and custom targeting parameters:

<amp-ad
  width="300"
  height="250"
  type="doubleclick"
  data-slot="/NETWORK_ID/ad-unit-path"
  data-multi-size="320x100,320x50,300x600"
  rtc-config='{
    "urls": [
      "https://prebid-server.pbstck.com/openrtb2/amp?tag_id=PUBSTACK_ADUNIT_NAME&account_id=PUBSTACK_SITE_ID&w=ATTR(width)&h=ATTR(height)&ms=ATTR(data-multi-size)&slot=ATTR(data-slot)&targeting=TGT&curl=CANONICAL_URL&timeout=TIMEOUT&adc=ADCID&purl=HREF&gdpr_consent=CONSENT_STRING&gdpr_applies=CONSENT_METADATA(gdprApplies)&consent_type=CONSENT_METADATA(consentStringType)"
    ],
    "timeoutMillis": 800
  }'
  json='{
    "targeting": {
      "category": "sport",
      "section": "homepage",
      "subsection": "football",
      "age": "25-34",
      "gender": "M",
      "region": "fr-ile-de-france",
      "device": "mobile",
      "user_id": "user_123456"
    }
  }'
></amp-ad>

How it works

  1. RTC Request: When the AMP page loads, the amp-ad component sends a request to Pubstack Prebid Server via the RTC protocol.

  2. Prebid Auction: Prebid Server runs the auction across connected SSPs/DSPs and returns the winning bid with targeting key-values.

  3. GAM Request: The AMP ad component automatically enriches the GAM request with Prebid targeting (hb_bidder, hb_pb, hb_cache_id, etc.).

  4. Creative Rendering: If a Prebid line item wins in GAM, the universal creative fetches and renders the winning ad from the Prebid cache.

Test & Debug

To troubleshoot your AMP integration:

  • Add &debug=true to the RTC URL to enable verbose logging

  • Check the browser console for RTC response data

  • Verify that targeting keys are being passed to GAM using Google Publisher Console

  • Ensure your CMP is correctly storing consent values before the ad request fires

Last updated