Common mistakes in new implementations

Wednesday, March 30, 2011 | 7:05 AM

Labels: ,

The first feature post in the new AdSense API blog is going to deal with something every AdSense API implementation must go through: the review process.

There are two steps to the review process: the technical review, and the policy review. We’ll be focusing on the first, and specifically the three most common mistakes that developers make while implementing API functionality into their platforms.

What do you mean, “Error”?

It’s important to not only tell users that a problem has happened, but also what the root cause of it was. It’s very common for a new implementation to point out that an error occurred, particularly during the account creation or association processes, but not whether it happened due to trying to create an already existing account, trying to associate with an account that does not exist, using the wrong postal code or telephone number, etc.

What to do:
AdSense API exceptions contain two fields that you can use to improve your error reporting: a message field, with a human-readable explanation of the error, as well as a numerical code field that allows you to handle different error types without resorting to message parsing or any other breakable approaches. The documentation contains a list of the different errors you can expect from each method after its description.

Account created - now what?

If your system does not insert ad code automatically into user content, it may be possible to forget one important step in account creating - generating at least one ad code. This is because there is some reporting functionality that only works correctly after ad code has been generated for an account; you can think of this as an initialization, or a setup step.

What to do:
Make sure that it’s not possible for a user to use their new AdSense account, created through your system, without having some ad code generation done on it. Usually, the easiest way of doing this is simply by requesting the code generation yourself. And feel free to discard the results, by the way, as only the side effects of the generation matter!


Changed my mind!

It’s important to make sure that not only can your users easily create new AdSense accounts, or associate with existing ones, but that they can also change their accounts later. While this may seem like a trivial requirement, it actually may take quite a bit of work, depending on how your system is implemented. For example, what happens to a user’s existing content when they change their AdSense account? Will it still show ads which are linked to the previous account?

What to do:
When a user changes accounts all of the existing ad code must be replaced with new ad code generated for the new account. This ensures that the traffic gets linked to the correct account. This operation can either be done automatically, especially if your system inserts the ad code into the user’s content without human intervention, or manually by making the user aware that they need to update their old content.


Great, what else?

This was just a small list of common issues that will hopefully help those of you out there that have already pulled your sleeves up and started coding. If you haven’t, however, keep an eye on this blog, as we’re preparing a series of blog posts that deal with creating an implementation from scratch following best practices. For any discussion, please check the AdSense API forum.

See you soon!

 - Sérgio Gomes, AdSense API Team