• Google Publisher Tag
Sign in
Guides Reference Samples Support
  • Google Publisher Tag
  • Guides
  • Reference
  • Samples
  • Support
  • Overview
  • Basic samples
    • Ad sizes
    • Configure personalized ads
    • Configure privacy settings
    • Display a test ad
    • Display a web interstitial ad
    • Display an anchor ad
    • Display an out-of-page ad
    • Key-value targeting
    • Reserve space for ads
  • Advanced samples
    • Ad event listeners
    • Collapse empty ad slots
    • Control SRA batching
    • Display a rewarded ad
    • Event-based ad requests
    • Lazy loading
    • Refresh ad slots
    • Tag pages with infinite content
  • Home
  • Products
  • Google Publisher Tag
  • Samples

Display a test ad

This example displays a test ad using the Google Publisher Tag library. See Get Started with Google Publisher Tags to learn more about how this sample works.

Sample implementation

View demo
Improve this sample Report an issue

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2022-03-18 UTC.

  • Connect

    • Blog
    • Facebook
    • Medium
    • Twitter
    • YouTube
  • Programs

    • Women Techmakers
    • Google Developer Groups
    • Google Developers Experts
    • Accelerators
    • Google Developer Student Clubs
  • Developer consoles

    • Google API Console
    • Google Cloud Platform Console
    • Google Play Console
    • Firebase Console
    • Actions on Google Console
    • Cast SDK Developer Console
    • Chrome Web Store Dashboard
Google Developers
  • Android
  • Chrome
  • Firebase
  • Google Cloud Platform
  • All products
  • Terms
  • Privacy
  • Sign up for the Google Developers newsletter Subscribe