Showing posts with label AdSense. Show all posts
Showing posts with label AdSense. Show all posts

AdSenseAccountStats App Reborn As AdsAccountStats - Finally

Is there a Windows app that can quickly show you the key metrics for your Google AdSense account?



Ah yes, wait a minute, there was this app called AdSenseAccountStats...  what happened to it again?Just kidding, check this post from a while back for an explanation why I had to pull it from the Microsoft Store.

AdSenseAccountStats Is Back - With A New Name


As mentioned in the previous post, I ended up simply renaming the app.  There is a bit of a process to step through, but luckily one can always find decent Microsoft knowledge articles on the interweb. If you are interested, check this blog post from the Windows App Consult Team.

In simple terms, follow these high level steps:

  1. Reserve new app name in the developer dashboard
  2. Update your manifest and app package, logos etc
  3. Create new store packages
  4. Create new submission and upload new packages
  5. Update your store listing details in the new submission
  6. Submit to store
  7. When approved and published, delete old app name
Refer to the above mentioned blog post for exact steps.  They all worked as described, although the 3rd step - creating new store packages - gave me some grief.   I experienced errors when building the release packages, complaining about the Display Name in the appxmanifest file.

The solution in the end was to re-create the package.xml file and re-associate the app with the Store, picking the new name (it eventually was visible and selectable in Visual Studio).  It did take a few attempts to get this right, but eventually came good.

Goodbye AdSenseAccountStats - Hello AdsAccountStats


Following this process should ensure that you don't lose the linkage of your app/packages and your app install base.  It is important to increment your version so that older packages will be deleted and apps updated to reflect the name name.

What next?  Go and get the app from the Microsoft Store of course 😀 if you don't have it already.  For now, there is no new or additional functionality, but when time permits there are a couple of improvements I would like to make and features to add.

Until then, enjoy the app once again as it stands.

MB.

AdSense Account Stats App Temporarily Unavailable in Microsoft Store


What happened to the AdSense Account Stats App in the Microsoft Store?


A couple of weeks ago I was notified by Microsoft that a third party agent working on behalf of Google has lodged a claim that the title of my AdSense Account Stats App in the Microsoft Store is infringing on a Google owned trademark.

The actual app title is AdSenseAccountStats, and I guess that has the word AdSense in it.  AdSense of course is indeed a Google owned trademark registered in the US, and quite possibly in many other countries.  Doing the right thing, I immediately removed the app from the store listing and download.

Now, I am neither a lawyer nor an expert with regard to trademarks, but one of the main aspects when it comes to trademark infringements is about potential consumer confusion.  Meaning that consumers might reasonably but incorrectly assume that a product or service is provided by the trademark owner when in reality that is not the case. Another aspect is about commerciality of the product or services infringing on a trademark.

You be the judge - is AdSenseAccountStats confusing?


Certainly a very interesting situation.  My app is of course available for free so there is no commercial benefit.  Additionally, Google do not have their own app in the Microsoft Store that one could use to access one's AdSense account.  On Android and Apple iOS such an official Google AdSense app exists, but not for Windows mobiles. Which incidentally was the key reason I put together the app in the first place.  I wanted an easy way to access my AdSense account from my Windows mobile.

As far as trademark infringement defenses go, there may be three interesting aspects here:
  • No real confusion of customers - title is simply describing what the app's purpose is
  • No commercial gain - the app is available free of charge and currently not ad supported
  • Abandonment of the Windows mobile platform - Google not providing its own app

Either way - Stand by for re-launch


Never mind, I have neither the time nor inclination to have an argument with the third party agent, so I guess I'll just rename the app and re-publish it with a more generic name.  In some ways, it is almost flattering that there is this much interest in an app I created.  It makes for a good story at the pub 😀

It is going to take a little while to relaunch the app however, so don't hold your breath.  There is a specific process to step through before the app can be re-enabled in the store.  Legal forms to submit, authorisation to be obtained, repackaging of the app with a new title (how does AdsAccountStats sound - generic enough?), submission update to the store and ultimately making the app available for download again.

Now if only I had a little spare time to do all the above...   I'll post again once the app is back and available.

'til then, have a great day.

MB

AdSense Account Stats UWP App Released

Introducing AdSenseAccountStats App

For all those AdSense account owners with Windows mobiles or tablets out there, I recently released a new UWP app that may come in handy. This simple app will allow you to quickly and easily check up on your AdSense performance.

Watch your monetization efforts pay off and your earnings grow

After logging in with your AdSense account and authorising the app for read-only access, you can easily see metrics such as:
  • Earnings Clicks, Cost Per Click
  • Page Views, Click Through Rate and RPM
  • Coverage

Code components that make it work

The app simply leverages Google APIs, specifically the AdSense Management API v1.4, and Google OAuth v2 for authentication of the user.  Basically, all calls to the AdSense APIs have to be authenticated or else they won't work.

So the first problem was to tackle Google OAuth v2 for a UWP app.  There are complexities around the Google provided libraries and support for UWP, and I have touched on these in another blog post.

OAuth v2 Authentication

The following code snippet deals with authentication successfully:

            UserCredential credential;
            try
            {
                using (var stream = new FileStream("client_secret.json", FileMode.Open, FileAccess.Read))
                {
                    credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
                        GoogleClientSecrets.Load(stream).Secrets,
                        new[] { AdSenseService.Scope.AdsenseReadonly },
                        "user",
                        CancellationToken.None,
                        new PasswordVaultDataStore()
                        );
                }
            }
            catch (UwpCodeReceiver.AuthenticateException ex)
            {
                // Login failed or authorisation not granted
                credential = null;
                await LoginFailed(ex);
            }
            catch (Exception ex)
            {
                credential = null;
                await SomethingWrong(ex);
            }

Creating a client service for your API calls

Once the user has logged on and authenticated their AdSense account, and granted permissions to the app so it can access the user's AdSense details, you then create a client service to use for your API calls.  Pass the credential object created by the code above to the http initializer.

            var adSenseService = new AdSenseService(new BaseClientService.Initializer()
            {
                HttpClientInitializer = credential,
                ApplicationName = "AdSense Accounts Stats",
            });

Setting up and executing an API request

After the user has logged on and allowed access for the app, the next piece is to construct a valid API request, execute it and handle the response in a meaningful way.  This can be achieved along the following lines:

            var earningsRequest = adSenseService.Reports.Generate(startString, endString);
            earningsRequest.Dimension = dimensionString;
            earningsRequest.UseTimezoneReporting = true;
            earningsRequest.Metric = new List<string>{ "earnings","page_views","individual_ad_impressions","clicks",
                                                "page_views_ctr","individual_ad_impressions_ctr",
                                                "page_views_rpm","individual_ad_impressions_rpm","cost_per_click",
                                                "ad_requests_coverage" };

            var earningsResponse = await earningsRequest.ExecuteAsync();

Once you have that response object, you can use it in any way you see fit, for example use its member items as a list source etc.

Hope you enjoyed this post and if you like go grab the app from the Microsoft Store.

Cheers

MB



Google OAuth2 for UWP C# XAML Apps Example

I have previously posted on consuming Google YouTube APIs in UWP C# XAML apps, showing how to consume Google APIs using the API key technique for authentication.

That technique works well, but has its drawbacks.  Mainly, you can't access any of the non-public user specific information that the APIs expose.  In other words, to get to the juicy bits you need to make authenticated Google API calls.  To do that, you need to work out Google OAuth2 authorisation flows.

Now, that's easier said than done if you are a part time hack like myself, and not a serious developer.  Through lack of skill I need to rely on the dotnet API libraries that Google kindly provides.  There are a good number of blog posts out there that detail the API key method, but not many that have a working example for using Google OAuth2 as per Google's developers API reference samples..

This is where this post kicks in.  But it also comes with a disclaimer (see below).  The following code snippet is an actual working example for a Google API OAuth2 authentication flow.  It uses the Google provided libraries which can readily be downloaded from Nuget and implemented in your project in Visual Studio.  Just use the Nuget Package Manager and search available packages for Google.Apis.

The magic sauce here is that the good folk at Google have fixed the OAuth flow for UWP C# only in a beta release of their dotnet libraries.  Specifically version 1.31.0 beta 01.  In the package manager, make sure to tick the box to include pre-releases, or else you won't get the beta on the list of available packages.


And here is the disclaimer... the mainstream release - currently up to 1.32.0 - does NOT work.  The code will build but fail at run time.

Enough said.  Following is the example code that will manage your Google OAuth2 authentication flow for you.  It prompts the user to log in with a Google account, authorise our example App, access the user's AdSense account, grab a list of payments for the account and finally display the results as the items source on a XAML ListView. Sounds tough?  Not really, just a few lines of code 😃

Of course, instead of accessing the AdSense Management API we could access the YouTube Data API or any of the other Google APIs presumably. I have only tested AdSense and YouTube, though.

     private async void PopulateAdsenseList()
     {
         UserCredential credential;
         using (var stream = new FileStream("client_secret.json", FileMode.Open, FileAccess.Read))
         {
             credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
                 GoogleClientSecrets.Load(stream).Secrets,
                 new[] { AdSenseService.Scope.AdsenseReadonly },
                 "user",
                 CancellationToken.None
                 );
         }
         var adSenseService = new AdSenseService(new BaseClientService.Initializer()
         {
             HttpClientInitializer = credential,
             ApplicationName = "Your App Name",
         });
         var myPayments = adSenseService.Payments.List().Execute();
         MyList.ItemsSource = myPayments.Items;
     }

Of course you will have to have a XAML page with a ListView (in this case called "MyList") to display the retrieved list of payments.

Just remember, don't be tempted to upgrade your Google.Api Nuget packages.  Stick with the 1.31.0. beta 01 release, or your code will break!  We'll have to wait until the devs at Google fix the libraries properly for UWP support.

Hopefully the above makes sense and you enjoyed reading this post.  If you have any questions or comments, why not drop me a line via email or comment below.

Cheers

MB


Most Popular Posts