A few weeks back we hosted a workshop for the Display Ads APIs and SDKs where we gave presentations on the DFP API, IMA SDK, and Mobile Ads SDK. If you weren’t able to attend, or want a refresher on something you saw that day, you can check out our presentation videos and slides. If you have any questions about those videos, feel free to ask on our respective forums:
Tag Archives: AdSense
Introducing DCM Reporting and Trafficking Services in Apps Script
Accessing the API from Apps Script is simple: just enable the service and it's ready to use. Authentication is handled automatically and editor conveniences such as autocomplete make it easy to start writing code right away. As an example, here's a snippet of code that shows how to list all user profiles available to your Google account:
To get started, check out the service documentation, which contains additional examples, as well as the full API reference documentation. If you have any questions, visit the API forum or reach out to Google Apps Script support.
function listUserProfiles() {
// Retrieve the list of available user profiles
var profiles = DoubleClickCampaigns.UserProfiles.list();
if (profiles.items) {
// Print out the user ID and name of each
for (var i = 0; i < profiles.items.length; i++) {
var profile = profiles.items[i];
Logger.log('Found profile with ID %s and name "%s".',
profile.profileId, profile.userName);
}
}
}
Source: Google Ads Developer Blog
From a DFP Line Item to Mobile Ads SDK Code
Imagine you’ve just finished creating a line item targeting mobile devices in DFP, and your manager comes to you and says, “Bad news! Our Android developer was just eaten by a bear, so now it’s your job to get that line item into our new app.” Don’t worry! Displaying DFP ads in Android applications is surprisingly easy.
First, check your configuration
If you’re already using the Mobile Ads SDK in your project, you’re ready to go. If not, check our quick starts for Android Studio and Eclipse to learn the best way to include the SDK.
Retrieve your ad unit ID and size
To display your new line item, you’ll need to retrieve its ad unit ID from DFP. Log into your account, locate the ad unit that targets the new line item, and look for a “Generate tags” button to the right of its name. Clicking that button will display a dialog with some options for the type of tag to generate:
Select “Mobile applications” in the Tag Type dropdown, and you’ll see the correct ad unit ID and ad unit size for your line item. Armed with those two pieces of info, you’re ready to start coding.
Place a PublisherAdView
DFP banner ads are displayed with the PublisherAdView class. It’s possible to create instances on the fly and add them to a layout programmatically, but the better practice is to define them in your XML layout files. Here’s an example element:
<com.google.android.gms.ads.doubleclick.PublisherAdView
android:id="@+id/banner_ad"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adSize="320x50"
ads:adUnitId="/1234567890/DemoAccount/BearRepellent"/>
Note the adSize and adUnitId attributes. These should be set to match the ad unit ID and size shown in the Generate Tags dialog. See our banner guide for more information about setting custom or multiple sizes.
Request an ad
With the PublisherAdView defined in your layout file, you just need to add a few lines of code to its corresponding Java class:
PublisherAdView adView = (PublisherAdView)findViewById(R.id.banner_ad);
PublisherAdRequest request = new PublisherAdRequest.Builder().build();
adView.loadAd(request);
PublisherAdRequest.Builder is a factory class that builds PublisherAdRequest objects. This example uses a simple, unmodified request, but there are a number of ways to add custom targeting, network extras, and test device information when building your own. See the targeting section of our banner guide for details.
Enjoy your line item
With the layout updated and request code in place, your app is ready to show an ad!
Feel free to use the code from this example in your own applications, and if you have any questions, come and see us on our forum.
Source: Google Ads Developer Blog
LineItemService, or Line_Item PQL Table?
One of the most used services in the DFP API is the LineItemService. Many of you are already utilizing the Line_Item table in the PublisherQueryLanguageService to create match tables on fields like Status
or ExternalId
, but with newer API versions, more and more fields are available as columns. Did you know that as of v201411 the Line_Item table includes a column for Targeting? With so many line item fields now accessible through PQL, the Line_Item table might be a viable replacement for your read operations.
What's the advantage? Faster response times. As an example, I pulled 5,000 line items from a network using both the LineItemService and the Line_Item PQL Table, printing page offsets as the results arrived. Take a look at the results:
Using the PublisherQueryLanguageService shaved off 17 seconds for a respectable speed increase of 15%.
However, if your application doesn't need some of the heavier fields, you'll see a much bigger gain. Check out what happens when we leave out Targeting:
The sparse selection offered by the PublisherQueryLangugeService means our data size is smaller, cutting the total time by a whopping 45%!
If you're looking for a performance boost in your LineItem read operations, give the Line_Item table a try. We've got example code in each of our client libraries to get you started. If you have any questions, don't hesitate to reach out to us on our API forums.
Source: Google Ads Developer Blog
We’re fixing an issue impacting Quality Score reporting in AdWords
If you read Quality Score metrics programmatically from the AdWords API, please be aware that the values reported by the API, starting from around 11am PT on March 26, 2015, may have been artificially low. Correct values are currently being restored, and should be fully stabilized within 24 hours.
This issue is limited to Quality Score reporting only. Auction time signals of quality, which are the signals actually used within the auction for computing Ad Rank and serving ads, are unaffected.
- Adam Ohren, AdWords API Team
Source: Google Ads Developer Blog
IMA Android SDK Beta 10 released
Today we're releasing Beta 10 of the IMA Android SDK. This is primarily a service release to address performance and bug fixes, but the release also includes some API changes to be aware of.
Changes in Beta 10
- Added
ImaSdkSettings.getMaxRedirects
andImaSdkSettings.setMaxRedirects
. - IMA API classes are now
final
. - The following
AdError.AdErrorCode
values have been removed: API_ERROR
- instead useUNKNOWN_AD_RESPONSE
.PLAYLIST_MALFORMED_RESPONSE
- instead useUNKNOWN_AD_RESPONSE
.REQUIRED_LISTENERS_NOT_ADDED
- was not being raised by the SDK.VAST_INVALID_URL
- instead useVAST_LOAD_TIMEOUT
.- Bug fixes.
Download IMA Android SDK Beta 10
You can get this latest release of the IMA Android SDK from our IMA SDK downloads page.
Check out the release notes page to stay up to date on IMA Android SDK releases.
Other questions?
As always, feel free to drop us a line on the IMA SDK forum and follow our Google+ page for other announcements and updates.
Source: Google Ads Developer Blog
New features in AdWords Scripts
AdWords API v201502 reports
AdWords scripts now support AdWords API v201502 reports. The new version introduces two new reports: USER_AD_DISTANCE_PERFORMANCE_REPORT and LABEL_REPORT. We also introduced several new columns, renamed some columns to make them consistent with the AdWords UI, and removed some duplicate columns. See the AdWords API release notes for more details.
If you use API versioning in your reports, you’ll need to modify your code to use v201502 as shown:
If you don’t use API versioning, your scripts will now default to v201502 reports. If your scripts access one of the removed or renamed columns, you may need to fix that column name in your scripts.
var report = AdWordsApp.report(query, {
apiVersion: 'v201502'
});
JDBC
JDBC allows your scripts to connect to external databases through the JDBC service, a wrapper around the standard Java Database Connectivity technology. In Apps Script, the JDBC service supports Google Cloud SQL, MySQL, Microsoft SQL Server, and Oracle databases. See our guide for more details.
If you have any questions about these features or AdWords scripts in general, you can post them on our developer forum.
Source: Google Ads Developer Blog
Shopping utility available in the AdWords API Java client library
The utilities let you focus on your use case, avoid boilerplate code, make your code more readable, and reduce the amount of code needed for common actions.
For example, the updated AddProductPartitionTree code sample that uses the utility is 65% shorter than the previous version.
Intrigued? Check out the product partition utility guide on github, and let us know what you think!
If you would like to have a similar utility in a different client library, register your interest by opening a github issue on that library's issues page.
Learn more
If you haven't started using Shopping campaigns, the following resources are a great place to start:
- Introduction to Shopping campaigns
- Shopping campaigns API guide
- API guide for transitioning to Shopping campaigns
Source: Google Ads Developer Blog
Announcing v7.0 of the Google Mobile Ads SDK for Android
Today we’re announcing the release of v7.0 of the Google Mobile Ads SDK! It’s listed as Google Play services (Rev. 23) in the Android SDK manager, and is available for download right now. Those of you using Android Studio can download Google Repository (Rev. 16) to get the latest Gradle artifacts. This release contains a number of stability and performance improvements, as well as some new features.
DFP developers can take advantage of two other new methods in PublisherAdRequest.Builder: addCustomTargeting and addCategoryExclusion.
Previously, developers had to add custom targeting information to a request by creating a Bundle and passing it to addNetworkExtrasBundle. This can now be done with a simple call to the addCustomTargeting method:
PublisherAdRequest newRequest = new PublisherAdRequest.Builder()
.addCustomTargeting("some_key", "some_value")
.addCustomTargeting("some_other_key", aListOfStringValues)
.build();
The new addCategoryExclusion method makes setting a slot-level category exclusion label for a request just as straightforward:
PublisherAdRequest newRequest = new PublisherAdRequest.Builder()
.addCategoryExclusion("some_unwanted_category")
.addCategoryExclusion("some_other_unwanted_category")
.build();
Another new feature is the setRequestAgent method that’s been added to AdRequest.Builder and PublisherAdRequest.Builder. Third party libraries that reference the Mobile Ads SDK should call this method to denote the platform from which the ad request originated. For example, if a third-party ad network called "CoolAds" mediates requests to the Mobile Ads SDK, it should call this method with "CoolAds":
AdRequest newRequest = new AdRequest.Builder()
.setRequestAgent("CoolAds")
.build();
This SDK release coincides with version 7.0 of Google Play services, which was recently announced on the Android Developer blog. For a full list of Mobile Ads SDK changes, check out our release notes. For technical questions, post them on our forum.
Source: Google Ads Developer Blog
Register now for the AdWords API Workshops around the globe!
Choose a location and type of event that best works for you and register soon! Wait for the confirmation email from our side.
This round we are hosting three variations of workshops:
- The Technical workshops are targeted for experienced API users, and we are going to talk about advanced use cases at a very technical level. If you are a developer, you are going to enjoy this event.
- The Introductory Technical workshop is similar to the technical workshops, but we are going to start with a use cases overview, and also talk about available tools on the market and best practices on API usage. This is still a technical workshop, but should be easy to consume by new developers and team managers. This round we will only be hosting this type of event in London (April 13th).
- The Business workshops are the new type of workshop. No technical content in terms of code, but instead we are going to talk about possible API use cases, and how to make your business work together with the AdWords API, or AdWords scripts. This is aimed at a business audience, so everyone can enjoy the event.
If you have any questions about the workshops, you can post them on our forums. Check out our Google+ page for Ads APIs updates.