Skip to main content
shortkit integrates with Google IMA SDK to deliver native in-feed video ads that match your app’s look and feel.

Overview

The ad integration architecture:
  1. SDK requests ad: Feed controller determines when an ad slot is due
  2. IMA SDK fetches ad: Requests ad from Google Ad Manager
  3. Native rendering: SDK renders ad in its own feed card with your styling
  4. Tracking compliance: SDK fires all required VAST tracking events

Account setup

Option 1: Self-managed

Use your own Google Ad Manager account:
1

Get your GAM credentials

From your Google Ad Manager account:
  • Network code
  • Ad unit ID for in-feed video
2

Configure in Admin Portal

  1. Go to Ads → Configuration
  2. Select Self-managed
  3. Enter your network code and ad unit ID
  4. Click Verify Connection
3

Map content categories

  1. Go to Ads → Configuration → Categories
  2. Map your content tags to IAB categories
  3. This enables targeted ad delivery

Option 2: Platform-managed

Let shortkit handle ad operations:
  1. Go to Ads → Configuration
  2. Select Platform-managed
  3. Complete enrollment form
  4. Our team sets up your inventory
  5. View revenue in the Ads dashboard
Platform-managed benefits:
  • Optimized fill rates and CPMs
  • No ad ops expertise required
  • Aggregate data improves targeting
  • Dedicated support

SDK configuration

Enable ads in your SDK configuration:
let config = ShortkitConfig(
    // ... other config
    ads: AdsConfig(
        enabled: true,
        frequency: .countBased(interval: 5, firstAdAfter: 3)
    )
)

Ad frequency modes

Count-based

Show an ad every N content videos:
ads: {
  frequency: {
    mode: 'count',
    interval: 5,      // Ad every 5 videos
    firstAdAfter: 3   // No ads until 3rd video
  }
}

Time-based

Show an ad every M minutes of watch time:
ads: {
  frequency: {
    mode: 'time',
    intervalMinutes: 3,      // Ad every 3 minutes
    minSessionMinutes: 1     // No ads in first minute
  }
}

Platform-optimized

Let the platform determine optimal frequency:
ads: {
  frequency: {
    mode: 'platform-optimized'
  }
}
Uses heuristics based on:
  • Session depth
  • Content completion rates
  • Aggregate engagement data

Native ad styling

Ads render as native feed cards matching your theme. Customize the sponsored label:
theme: {
  sponsoredLabel: {
    text: 'Ad',
    textColor: '#FFFFFF',
    backgroundColor: 'rgba(0, 0, 0, 0.7)',
    fontSize: 11,
    position: 'topRight'
  }
}

Styling options

OptionDescription
textLabel text: “Ad”, “Sponsored”, etc.
textColorLabel text color
backgroundColorLabel background color
fontSizeText size in points
positionCorner: topLeft, topRight, bottomLeft, bottomRight

Ad events

Handle ad-related events in your app:
class AdEventHandler: ShortkitDelegate {
    func shortKit(_ shortKit: shortkit, didShowAd ad: Ad) {
        analytics.track("ad_impression", properties: [
            "adId": ad.id,
            "position": ad.position
        ])
    }

    func shortKit(_ shortKit: shortkit, didCompleteAd ad: Ad) {
        analytics.track("ad_completed", properties: [
            "adId": ad.id,
            "watchTime": ad.watchTime
        ])
    }

    func shortKit(_ shortKit: shortkit, adDidFail error: AdError) {
        print("Ad failed: \(error.message)")
    }
}

Available events

EventDescription
adImpressionAd rendered in feed
adStartedAd playback began
adFirstQuartile25% of ad watched
adMidpoint50% of ad watched
adThirdQuartile75% of ad watched
adCompletedAd finished playing
adSkippedUser skipped the ad
adClickedUser tapped the ad
adErrorAd failed to load or play

VAST compliance

The SDK automatically handles VAST tracking requirements:
  • Impression tracking
  • Quartile events (25%, 50%, 75%)
  • Completion tracking
  • Click tracking
  • Error reporting
This ensures accurate reporting in Google Ad Manager and proper billing.

Testing ads

Test mode

Enable test ads during development:
shortkit.initialize({
  apiKey: 'pk_live_...',
  config: {
    ads: {
      enabled: true,
      testMode: true  // Shows test ads
    }
  }
});
Test mode:
  • Shows Google test ad creatives
  • No real impressions recorded
  • No revenue generated

Ad Inspector

Debug ad delivery:
  1. Enable debug logging
  2. View ad request/response in console
  3. Check fill status and errors
shortkit.setLogLevel('verbose');

Best practices

Begin with 1 ad every 6-8 videos. Monitor retention metrics before increasing.
Track session length and return rates. If they drop after changing ad frequency, roll back.
Test different frequencies to find the optimal balance between revenue and engagement.
Native-looking ads perform better and annoy users less than disruptive formats.
Map content categories carefully to avoid inappropriate ad/content combinations.

Next steps