GAM setup iOS

Setting up Google Ad Manager (GAM) for iOS involves several steps, including integrating the GAM SDK, creating ad units, setting up line items and creatives, and configuring your app's settings within GAM. Here's a step-by-step guide to help you set up GAM for iOS:

Step 1: Create a Google Ad Manager Account

If you don't have a Google Ad Manager account, you'll need to create one by visiting https://admanager.google.com and signing up.

Step 2: Set Up an Application in Google Ad Manager

  1. Log in to your Google Ad Manager account.
  2. Click on "Inventory" in the left sidebar.
  3. Under "Ad units," click "Ad units."
  4. Click the "+ New ad unit" button.
  5. Fill in the ad unit details, including the name, ad type (e.g., banner, interstitial), size, and targeting options.
  6. Save the ad unit and take note of the ad unit ID.

Step 3: Integrate the GAM SDK into Your iOS App

  1. Download the GAM SDK for iOS from the Google Ad Manager SDK download page.
  2. Add the GAM SDK to your Xcode project:
    • Drag the GoogleMobileAds.framework into your project.
    • Make sure it's added to your app's target.
  3. Add the necessary frameworks and libraries:
    • In your project settings, navigate to the "General" tab.
    • Scroll down to the "Frameworks, Libraries, and Embedded Content" section.
    • Add the following frameworks:
      • AdSupport.framework
      • AudioToolbox.framework
      • AVFoundation.framework
      • CoreGraphics.framework
      • CoreMedia.framework
      • CoreTelephony.framework
      • EventKit.framework
      • EventKitUI.framework
      • MessageUI.framework
      • StoreKit.framework
      • SystemConfiguration.framework
      • UIKit.framework
    • Ensure that the frameworks are set to "Embed & Sign."

Step 4: Initialize the GAM SDK in Your App

  1. In your app's AppDelegate.swift, import the GAM SDK:
    import GoogleMobileAds
  2. In the application(_:didFinishLaunchingWithOptions:) method, add the following code to initialize the GAM SDK with your Ad Manager app ID:
    GADMobileAds.sharedInstance().start(completionHandler: nil)

Step 5: Request and Display Ads

  1. In the view controller where you want to display ads, import the GAM SDK:
    import GoogleMobileAds
  2. Create an instance of DFPBannerView or DFPInterstitial (for interstitial ads).
  3. Set up the ad unit ID:
    let adUnitID = "YOUR_AD_UNIT_ID"
    bannerView.adUnitID = adUnitID
  4. Load and display the ad:
    bannerView.load(GADRequest())

That's it! You've successfully integrated the GAM SDK into your iOS app and set up an ad unit. Remember to replace "YOUR_AD_UNIT_ID" with the actual ad unit ID you obtained from GAM.

Additional Steps

  • For interstitial ads, you'll need to create a DFPInterstitialDelegate to handle ad events and present the interstitial when it's ready.
  • Implement ad event listeners to handle ad lifecycle events, such as ad loaded, ad failed to load, ad clicked, etc.

Please refer to the Google Ad Manager iOS SDK documentation for more detailed information, guides, and code examples. You can also check our github example.

© 2024 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.