Can I use Google Adsense For Search (AFS) ad units with AMP? - adsense

I need to put on my site Google Adsense for Search(AFS) ad units (see screenshot).
But I'm looking in AMP documentation and don't find this ad type here.
https://www.ampproject.org/docs/reference/amp-ad.html
Is there a way to do this or AMP is not supporting these ads?
Regards, Kadmos

There's a Github issue discussing this topic: https://github.com/ampproject/amphtml/issues/2659
If the integration you want is this: https://support.google.com/adsense/answer/9879?hl=en then you should experiment with putting it inside an amp-iframe.

Yes, it is possible to put CSA ads on AMP pages
<amp-ad width=auto height=300
type='csa'
layout='fixed-height'
data-afs-page-options='{"pubId": "partner-pub-id", "query": "flowers"}'
data-afs-adblock-options='{"width": "auto", "number": 2}'>
</amp-ad>
https://github.com/ampproject/amphtml/blob/master/ads/google/csa.md

AMP currently supported providers like AdSense. You can place ads on your page by using the amp-ad component. See the sample snippet.
<amp-ad width="320" height="250"
type="adsense"
data-ad-client="ca-pub-8125901705757971"
data-ad-slot="7783467241">
</amp-ad>
You need to specify which provider you want on the type attribute and then set up some other attributes that are specific to that provider.
You can also check this blog for reference.

Related

How to create a Facebook ad based on a post?

After many tries, I'm not getting how we can use the Facebook API to create a simple Ad based on a Post (and it's creative) like it is possible in the Business Manager.
For example, my last attempt failed due to a problem with Instagram:
Facebook API: Instagram Account Is Missing
If there is anybody that has been able to create a basic Ad (within a given or new AdSet) based on a Post, please help me. I've seen many questons like this (especially regarding the Instagram problem) and now I'd like to have a working solution.
What exact requests have to be done or isn't it possible at all?
THe Instagram placement is added by default in the targeting, so if you want to skip it you need to specify in the targeting field when creating the adSet in the publisher field:
{
"geo_locations":{"countries":["US"]},
publisher_platforms: ['facebook'],
facebook_positions: ['feed', 'right_hand_column'],
device_platforms: ['mobile', 'desktop']
}
If you want to publish on Instagram also you should also provide an instagram actor ID: The AdsCreative should contain an extra field named instagram_actor_id also remember to add Instagram in the related targeting:
{
"geo_locations":{"countries":["US"]},
publisher_platforms: ['facebook','instagram'],
facebook_positions: ['feed', 'right_hand_column'],
instagram_positions: ['stream', 'story'],
device_platforms: ['mobile', 'desktop']
}
Reference:
https://developers.facebook.com/docs/marketing-api/guides/instagramads
https://developers.facebook.com/docs/marketing-api/guides/instagramads/ads_management/
https://developers.facebook.com/docs/marketing-api/targeting-specs/#placement
Let me know if you need more info or an answer or your other question about Instragam

Unable to get ad preview using facebook graph api?

Using the information from this documentation to generate iframe of the ad preview (in Facebook Graph API),
According to the documentation, we need to use the following URL
https://graph.facebook.com/v2.8/{adgroup-id}/previews/ad_format=
Not able to understand how to pass in the ad_format. It is compulsory to pass this parameter.
GET parameters are passed like:
https://graph.facebook.com/v2.8/{adgroup-id}/previews/?ad_format=DESKTOP_FEED_STANDARD
This question is old. But in order to run a preview you need to pass two parameters:
ad_format
There are various types of ad_formats: You generally use them according to your specific use. For basic mobile and desktop testing
DESKTOP_FEED_STANDARD, MOBILE_FEED_BASIC, MOBILE_FEED_STANDARD, MOBILE_FULLWIDTH will work fine
access_token
So your URL will be of the format :
https://graph.facebook.com/v4.0/AD_ID/previews?access_token=ACCESS_TOKEN&ad_format=DESKTOP_FEED_STANDARD

Creating saved target group in facebook audience

I need to create Saved Target Group in facebook programmatically like PowerEditor does it here https://www.facebook.com/ads/manage/powereditor.
During inspecting the browser's console when saving through the Power Editor I've discovered that such kind of an endpoint is used:
"https://graph.facebook.com/v2.2/act_#AD_ACCOUNT_ID#/audiences", but the method called is encrypted and there is no information about this kind of endpoint in the facebook API documentation.
Seems like Power Editor uses more extended API or not all the API is well documented.
Did anybody experience something similar?
Thanks
Not all of the functionality available in Power Editor is available in the public API or vice versa -
If what you're asking about is not in the public API documentation, it's not part of the API that is available publicly -
It would be dangerous to assume that an undocumented endpoint will continue to work or that it works in a specific way based on observing another app (Power Editor) calling it
You can use saved_audiences API.
Here is Graph Explorer request examples:
POST:
https://developers.facebook.com/tools/explorer/765026780221012?method=POST&path=act_&Fsaved_audiences&version=v2.5&name=foo&targeting={ "age_min":18, "age_max":65, "page_types":[ "desktop-and-mobile-and-external" ], "geo_locations":{ "countries":[ "US" ], "location_types":[ "home" ] } }
GET ALL:
https://developers.facebook.com/tools/explorer/765026780221012?method=GET&path=act_%2Fsaved_audiences&version=v2.5

Facebook Audience Network with dfp mediation network

App
It already uses dfp to get ads from admob as described in DFP Android Guides. Now I want to get ads from facebook audience network through dfp. I follow the guide here and add FacebookAdapter.jar and AudienceNetwork.jar into my app.
DFP
In my line item, I set type price priority and use sdk mediation ad with facebook audience network.
Condition
However, when the app runs, I see the following message just like someone else reported here.
W/FacebookAdapter(18649): The input ad size is not supported at this moment.
I think the code works, and dfp delivers the ads from facebook audience network. I am pretty sure about this because both dfp and facebook console show the ad request information.
Questions
Do I setup the line item correctly?
How could we fix the issue of unsupported ad size?
Update
Nothing wrong about the line item setting. But if you use dfp for mediation, you need to be aware of the priority here
Currently, the simplest solution is to give up smart banner and use banner instead. This would allow you to get mediation ad from facebook audience network.
Don't forget to add -keep public class com.google.ads.mediation.** {*;} if you use proguard. Otherwise, you will see couldn't instantiate facebook adapter message.
I use dfp sdk so if you use other sdk, I cannot guarantee it works. My code already works for admob and other mediation network, and I try to add facebook audience network.
layout.xml
<com.google.android.gms.ads.doubleclick.PublisherAdView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="#+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="#string/ad_unit_id"
android:visibility="gone" />
Note that I use BANNER instead of SMART_BANNER here, somehow, the banner size is incompatible between dfp and facebook. In my opinion, this is an issue of sdk. I hope google would fix this later, but I just give up SMART_BANNER for now. As I mentioned in the update, if you use SMART_BANNER, you will get this W/FacebookAdapter(18649): The input ad size is not supported at this moment.
jar
facebook android sdk - This one is from facebook, and you can find the AudienceNetwork.jar in it.
facebook adapter - This is from dfp mediation network, and you can find FacebookAdapter.jar.
In Android Studio, all you need to do is put jars in your libs folder and make sure your build.gradle includes the libs folder.
build.gradle
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
...
}
Somehow, when I build the apk, the libraries are not compiled even when I Synchronize 'build.gradle'. Hence, you might want to check your project.iml and make sure you see the following in it.
project.iml
...
<orderEntry type="library" exported="" name="AudienceNetwork" level="project" />
<orderEntry type="library" exported="" name="FacebookAdapter" level="project" />
Proguard
As I said in the reply, you must not forget to add com.google.ads.mediation if you use Proguard! Otherwise, you will keep seeing cannot instantiate com.google.ads.mediation.facebookadapter class.
-keep public class com.google.ads.mediation.** { public *; }
Log
This is the message you will see if everything is configured properly.
02-18 16:24:25.315 8081-8307/com.xxxxxxx I/Ads﹕ Trying mediation network: 1.0568273599589929E19
02-18 16:24:25.320 8081-8081/com.xxxxxxx I/Ads﹕ Instantiating mediation adapter: com.google.ads.mediation.facebook.FacebookAdapter
02-18 16:24:25.335 8081-8081/com.xxxxxxx W/Ads﹕ Server parameters: {"gwhirl_share_location":"1","pubid":"xxxxxxxxxxxxx_xxxxxxxxxxxxx"}
This is the simplest way to use Audience Network if you are willing to give up SMART BANNER. If you must use SMART BANNER, I suggest you to implement custom event banner using com.google.ads.mediation.customevent.CustomEventBanner yourself. In Vpon's Google Admob Mediation, it shows an example of implementation of custom evener banner. I think you will be able to use SMART_BANNER in this way, and it also means that you have to convert the ad size yourself.
Update
Targeting
I am actually not sure about if you can do targeting with facebook audience network or not because I cannot find anything about targeting in facebook's official document.
You can see dfp Custom targeting for this, and I guess the code would be something like .addNetworkExtrasBundle(new com.google.ads.mediation.facebook.FacebookAdapter(), bundle).
Placement id
In case you're not familiar with how to use placement_id you get from facebook audience network, you have to do the following things:
Create a line order
Create a line item
Create a SDK mediation creative
Select Facebook Audience Network like the image below and put your placement id there.
This is the very simple version of how you do it, and you should know that the setting of line item will have effects on ads. If you settings are not correct, for example, the item's type priority is too low or frequency capping is too long, you might not see the ads.
Feb 2016
You can use gradle to install audience network library now.
compile 'com.facebook.android:audience-network-sdk:4.+'
More information at Using the Native Ad API in Android
If you see the following messages without delivering any ad, that is probably because you don't have facebook app installed on your device or emulator.
E/ActivityThread: Failed to find provider info for com.facebook.katana.provider.AttributionIdProvider
W/FacebookAdapter: No fill. We are not able to serve ads to this person. Please refer to https://developers.facebook.com/docs/audience-network/faq#a12. If you are integrating Audience Network for the first time, you can use test ads https://developers.facebook.com/docs/audience-network/testing.
May 2016
Yoann Hercouet points out in the comments that LARGE_BANNER is also not available on Facebook.
there is a adsize matching issue inside the FacebookAdapter:
https://groups.google.com/forum/#!category-topic/google-admob-ads-sdk/android/MWoBWBR0FQM

iPhone facebook integration

I am using Graph API in my application. I am fetching user's facebook wall feeds using graph API also getting details of particular post i.e (Like count,Comments etc).
but i want to allow user to Like and Comment any post from the application itself.
what is the request format for that?
Please help me or give any pointers.
Regards,
Sanket
You would be well served to check out the Publishing section of the documentation. It provides information such as this.
One example is liking, which is defined as:
Method: /OBJECT_ID/likes
Description: Like the given object (if it has a /likes connection)
Arguments: none
Basically, just initiate a Graph API call to something like:
[facebookObject requestWithGraphPath:#"98423808305/likes" andDelegate:self];
That will "like" a picture from Coca-Cola (ID taken from the documentation).
Edit 1
According to the documentation:
Most write operations require extended permissions for the active user. See the authentication guide for details on how you can request extended permissions from the user during the authentication step.
Are you sure you have enough privileges? Unfortunately the documentation is very unclear as to whether it serves the dual purpose of liking the object and returning the likes already on that object.
Edit 2
I did some more research into what could be causing this and came across this question and answer that indicated that the code I posted above using requestWithGraphPath:: should work. However, it does not due to a bug on Facebook's Bug Tracker.
Unfortunately, it looks like there is no way to "like" an object via the Graph API, which seems very strange to me. Perhaps it is possible with the legacy REST API instead of the Graph API?
Edit 3
Well, it looks like your best bet is the stream.addLike method of the legacy REST API which you can still call using the Facebook iOS SDK. You should be able to use the stream.addLike method to "like" something in the "stream". Unfortunately, it doesn't appear to support photos, videos, etc. Only posts and comments.
Finally i found the solution for LIKE option
We should use following method for like option.
-(void) requestWithGraphPath:(NSString *)graphPath
andParams:(NSMutableDictionary *)params
andHttpMethod:(NSString *)httpMethod
andDelegate:(id <FBRequestDelegate>)delegate
graphPath = /OBJECT_ID/likes
Paramas = dictionary with comment ,for like option use empty dictionary
HttpMethod should be POST
you should get response = true if the LIKE request is successful.