DFP NativeCustomTemplateAd and ClickListener - Impossible to fall back to the "Clickthrough URL"

212 views
Skip to first unread message

jar...@2appaz.com

unread,
Aug 8, 2016, 6:01:39 AM8/8/16
to Google Mobile Ads SDK Developers
Hello,

I am using DFP to display Native ads in my application (v9.4.0 of the Play Services).
In my case, I have two scenarios that can happen when the ad has been clicked : 
1. in some cases, I would like to handle the click myself
2. in others, I would like the SDK to redirect the user to the "Clickthrough URL"

Looking at the methods provided by the SDK, it doesn't seem possible at the moment : we can only always intercept clicks and handle them ourselves or always letting the SDK taking care of the click. There doesn't seem to be a middle ground.

From what I gathered, you have to know before loading your Ad (and your custom template) if you want to handle the click because that's the only moment you can attach a OnCustomClickListener:
AdLoader adLoader = new AdLoader.Builder(context, "/6499/example/native")
   
.forCustomTemplateAd("10063170",
     
new OnCustomTemplateAdLoadedListener() {
       
// Display the ad.
     
},
     
new OnCustomClickListener() {
         
@Override
         
public void onCustomClick(NativeCustomTemplateAd ad, String assetName) {
           
Log.i("MyApp", "A custom click just happened for " + assetName + "!");
         
}
     
}
).build();


To resolve my case I would like to attach a OnCustomClickListener only after I received the TemplateAd and its custom information, most likely by setting it on the NativeCustomTemplateAd received.
Another way would be to be able in the CustomClickListener to fallback to the SDK if we don't want to handle the click anymore (for example by returning a boolean specifying whether we did handle the click or not).

Do you know of any way I could implement those functionnalities? 
If not, I'm thinking about inserting a new field in my custom template repeating the "Clickthrough URL" in order to make the redirect by myself in the CustomClickListener... Do you have any counter-arguments on doing that?

Thanks

Veer Arjun Busani(Mobile Ads SDK Team)

unread,
Aug 8, 2016, 2:08:32 PM8/8/16
to Google Mobile Ads SDK Developers
Hi there,

Your third point, where you would have to define another url variable, which you can load using its VariableID, would be the ideal way to go about this. Simply add this variable and load up the Click-through URL manually if you are going to implement custom clicks. Also, I would bring your middle ground suggestions with the team and thank you for your feedback!

Do let us know if you need anything else.

Thanks,
Veer Busani
Mobile Ads SDK Team
Reply all
Reply to author
Forward
0 new messages