question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AdManagerAdRequest - Custom targeting

See original GitHub issue

Plugin Version

2.0.1

Steps to Reproduce

  1. Set up the google mobile ad
  2. Set up AdManagerAdRequest with a customTargeting.
  3. Enable Network tracing
  4. See the onNetworkRequest logs on your console. The requested URL is in params.firstline.uri.

Expected results: See the custom values on the request URL.

Actual results: Nothing changed.

Logs
--
flutter analyze
Analyzing ads...
No issues found! (ran in 0.9s)
[✓] Flutter (Channel stable, 3.0.5, on macOS 12.5.1 21G83 darwin-arm, locale en-BR)
    • Flutter version 3.0.5 at /Users/eliasreis/Development/flutter/flutter-3-0-5
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision f1875d570e (8 weeks ago), 2022-07-13 11:24:16 -0700
    • Engine revision e85ea0e79c
    • Dart version 2.17.6
    • DevTools version 2.12.2

[✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
    • Android SDK at /Users/eliasreis/Library/Android/sdk
    • Platform android-32, build-tools 32.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.4.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)

[✓] VS Code (version 1.70.2)
    • VS Code at /Users/eliasreis/Downloads/Visual Studio Code 2.app/Contents
    • Flutter extension version 3.46.0

[✓] VS Code (version 1.64.2)
    • VS Code at /Users/eliasreis/Downloads/Visual Studio Code.app/Contents
    • Flutter extension version 3.46.0

[✓] Connected device (3 available)
    • sdk gphone64 arm64 (mobile) • emulator-5554 • android-arm64  • Android 13 (API 33) (emulator)
    • macOS (desktop)             • macos         • darwin-arm64   • macOS 12.5.1 21G83 darwin-arm
    • Chrome (web)                • chrome        • web-javascript • Google Chrome 105.0.5195.102

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

Basically, what I would expect with this:

    final adManagerAdRequest = AdManagerAdRequest(
      customTargeting: {
        'appversion': '0.0.1',
      },
    );

      _ad = AdManagerBannerAd(
        adUnitId: widget.adUnitId ??
            (widget.isIos
                ? BannerAdContent.iosTestUnitAd
                : BannerAdContent.androidTestUnitId),
        request: adManagerAdRequest,
        sizes: [AdSize.mediumRectangle],
        listener: AdManagerBannerAdListener(
          onAdLoaded: _onAdLoaded,
          onAdFailedToLoad: (_, error) {
            if (mounted) setState(() => _adFailedToLoad = true);
          },
        ),
      )..load(),

Would be a urlParam called cust_params with appversion key and value as 0.0.1, but It’s not working, do you have any idea why?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:14

github_iconTop GitHub Comments

2reactions
jjliu15commented, Sep 9, 2022

Hi @eliasreis54, by any chance is BannerAdContent.androidTestUnitId an Admob ad unit? Does it look like ca-app-pub-…? I think what’s happening is that cust_params is not included for admob ad units, since it’s an ad manager feature.

I tried updating the AdManager banner example from the example app and was able to see custom_params in the ad request from debug logs:

/Ads     (16315): GMA Debug BEGIN
I/Ads     (16315): GMA Debug CONTENT {"timestamp":1662764067758,"event":"onNetworkRequest","components":["network_request_ae60c449-05f2-4ee6-970d-1eeb690593fd"],"params":{"firstline":{"uri":"https://pubads.g.doubleclick.net/gampad/ads?submodel=Pixel%202&android_app_volume=1&disable_ml=false&format=320x100_as&omid_v=a.1.3.31-google_20220407&android_app_muted=false&am=0&dv=222508000&gl=US&hl=en&js=afma-sdk-a-v222508999.221310000.1&lv=221310600&ms=CtQDmsA_ATEaOgH2YOg5YdLsdMQUVuF1WwSah6d7qQlTUcFJ7YVbrIFobUCRGxZQwbCHcI1IHbQc7Pa17eGfGypu1-USkAOcFwQOBuYbF4JX2HlQCQezpQgu5I1jHJCyTWGlg1kqiEkKbai_WtHnr2JPkYGFzRS5B-oUToW88rOzVSOF-yYc8_lhTUBs0IP7ztU4Kuv1G4FkDVTE4q3mGQG43biqfnOUfXwa-tjoEqSlfy_dTZjIt0TkSuELcmAFlx1zlLb6hHXXTuvGEVM_Ze2nWfztLtpHGFholMesQklfeiZnhELQ4OyU4A7rxJetV3QQ3PN7w9WlX8AAapGbt_ieo4VpizHbYsGHhwazKkTDGhTF6qqpC-AIupA41_yM-i-gJsDpYxHbfdPdMD9BdBe_XdSebNG10hHIdvoeOFD0Iji6ajVRu9Nphu8-Qt1HmMI4vVxg53olulmVIiJDyVx327hLgaLxgbwKAthy-AJTy91yF-nKXYw1jSGHbvg6qlt1EJRjy83lLg6FZYYdwh7A5CkrSTH6h8LRf4XbHLbHmlLnTLpnP6hNgTyHXUFyZcDKpwW8x0sAm7gmo3DAK6g59ZIC30wtnsZhQOr7dSzqORQHU2ExIAQ&mv=83181910.com.android.vending&vnm=1.0&u_sd=2.625&request_id=805801515&render_in_browser=false&target_api=31&is_sidewinder=false&request_agent=Flutter-GMA-2.0.1&fbs_aeid=3190920203574234007&fbs_aiid=fe821411d9ab9988b48112f609f594fd&seq_num=6&eid=318496669%2C318500618%2C318486317%2C318491267%2C318482459%2C318482960%2C318483611%2C318484497%2C318492497%2C318500128%2C318500151%2C318500347%2C318501466%2C318502960%2C318504146%2C318502753&npa=1&guci=0.0.0.0.0.0.0.8&sdk_apis=7%2C8&omid_p=Google%2Fafma-sdk-a-v222508999.221310000.1&u_w=412&u_h=684&msid=io.flutter.plugins.googlemobileadsexample&an=1.android.io.flutter.plugins.googlemobileadsexample&u_audio=3&net=wi&u_so=p&preqs_in_session=32&support_transparent_background=true&preqs=5&time_in_session=476930&output=html&region=mobile_app&u_tz=-420&url=1.android.io.flutter.plugins.googlemobileadsexample.adsenseformobileapps.com&gdfp_req=1&m_ast=afmajs&impl=ifr&iu=%2F6499%2Fexample%2Fbanner&sz=320x100&correlator=2608407067745605&gsb=wi&ogsb=wi&apm_app_id=ca-app-pub-3940256099942544~3347511713&apm_app_type=2&lite=0&caps=inlineVideo_interactiveVideo_mraid1_mraid2_mraid3_sdkVideo_exo3_th_autoplay_mediation_scroll_av_av_transparentBackground_sdkAdmobApiForAds_di_sfv_dinm_dim_nav_navc_dinmo_ipdof_gls_gcache_xSeconds&bisch=true&blev=0.55&canm=false&_mv=29.android&heap_free=855597&heap_max=201326592&heap_total=6538749&wv_count=2&rdps=38850&cust_params=excl_cat%26appversion%3D1.0.0&includeDoritos=true&includeCookies=true&rdidl=36&idtypel=4&is_latl=-1&blob=ABPQqLGAiE50Jj2XfYn2QZRCAvSAVwW_Wx1Iv7z4Qtu68xJ48m22rUbej2dLtvSxF1Kf4LV9XpgJ8WJ1lalqxAtlV6ev-lLJwO0O4rLGnX31qUvMgw5MgZgBYVJMcHjwnTS_nRQuOL8MRQUclvJCqhx0Dvx0hRx6TamgW5sl_Mkpd3cIAQAdfg3EgaNf6nPCD6H2z0fQUCeDY6-io_EEUwCFqENIVF_9b_fwlzuAZJ1-FU4naI_KUHxNJoDPcdxUk5NaFv_UwfFLlhOBf_Kkf7taqb8gkdtCLAH12wE50kHB1ioypgs7aEr_oW0I6MdNoSXdAzrPB5w8-z6Ya_A&et=6&jsv=sdk_20190107_RC02-production-sdk_20220901_RC00&tcar=10#caps=inlineVideo_interactiveVideo_mraid1_mraid2_mraid3_sdkVideo_exo3_th_autoplay_mediation_scroll_av_av_transparentBackground_sdkAdmobApiForAds_di_sfv_dinm_dim_nav_navc_dinmo_ipdof_gls_gcache_xSeconds&eid=318496669%252C318500618%252C318486317%252C318491267%252C318482459%252C318482960%252C318483611%252C318484497%252C318492497%252C318500128%252C318500151%252C318500347%252C318501466%252C318502960%252C318504146%252C318502753&format=320x100_as&heap_free=855597&heap_max=201326592&heap_total=6538749&js=afma-sdk-a-v222508999.221310000.1&msid=io.flutter.plugins.googlemobileadsexample&preqs=5&seq_num=6&target_api=31","

However after changing the ad unit to an admob ad unit it looks like cust_params is no longer in the ad request.

@huycozy in your example it also looks like an admob ad unit. If you change the ad unit to /6499/example/banner you should see cust_params appear as well. Separately, we should probably update the inline adaptive example to use an ad manager ad unit to avoid confusion.

1reaction
huycozycommented, Sep 27, 2022

@eliasreis54 Thanks for contributing a PR, let @jjliu15 give more comments on this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Targeting | Mobile Ads SDK for Android - Google Developers
The AdManagerAdRequest object collects targeting information to be sent with an ad request. Custom targeting. You can pass custom key-value pairs to target ......
Read more >
Targeting types - Google Ad Manager Help
Custom targeting allows you to include key-values, audience segments, or content metadata for video line items if Video Solutions is activated in your...
Read more >
AdManagerAdRequest | Firebase - Google
An AdManagerAdRequest contains targeting information used to fetch an ad from Google Ad Manager. Ad requests are created using AdManagerAdRequest.Builder .
Read more >
AdManagerAdRequest class - google_mobile_ads library
API docs for the AdManagerAdRequest class from the google_mobile_ads library, for the Dart programming ... Key-value pairs used for custom targeting.
Read more >
Targeting | Mobile Ads SDK for Android | Google Developers
Example: Pass custom targeting "age=25". AdManagerAdRequest newRequest = new AdManagerAdRequest.Builder() .addCustomTargeting("age", "25") .build();
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found