Pages

Sunday, July 30, 2017

Episode 546: Analystic API Request In Monday Morning

Is it an analysis tool, or an aggregation tool?

Anyone who is involved in the web industry knows about the existence of "Google Analytics".

Although I might not need to explain again, "Google Analytics" is a service that is to know the number of visits and visitors on particular website, and it is an indispensable tool for people who work in the industry, for surveying such as "popular pages" and "unpopular pages" or "investment effect of online ads".

On the other hand, for many people it can be said "a too much functional tool".

In order to display the information which you want to see, you must go through complicated procedures because its multifunctionality. Even those who log in to "Google Analytics" every week, to make "in-house weekly newsletter" for example, actually use only a few functions of it. Therefore, many people use "custom reports" (dashboards) and "custom alerts" (email notifications) trying to make the every time work efficient.

No abnormality in aggregated value this week!

The following Business Process Definition is "Website Operation Status Reporting Process" to be conducted weekly. Every Monday morning, "a draft of report that aggregated data of Google Analytics has been inserted" will be prepared. Therefore, marketers can complete a report for the entire company just by entering a brief commentary. You do not need to log into "Google Analytics" unless remarkable changes occur.

[Website Operation Report]


Automatic access to API

In this example, the inquiries will be made automatically to "Google Analytics" at 6:30 am on Monday morning.

Specifically, an Issue of reporting is automatically Started by "Timer Start Event" at "6:30 on Monday morning". And immediately after that, the Workflow system (Questetra) makes request communication toward "Google Analytics Reporting API v4" (OAuth 2 communication) automatically. (Request to Analytics step)

After that, when the marketing staff completes "Report preparation", "report" is transmitted at the "Email sending event" at the downstream to the internal mailing list. (Of course, you may also want to consider flow expansion such as having a person in charge other than the marketing team enter comments, or automatically posting to Slack etc.)

In addition, even if the marketing person did not complete the preparation of the report, the report (the draft as it is) sentence will be sent automatically to the internal mailing list 3 hours after started (9:30).

Automatically acquiring ranking information

Several settings are necessary for the automatic step (Service Task Addon) used here.
  • Authorization setting name: Name when setting Access API, Scope, etc.
  • View ID: Access log to be counted (*)
  • Number of items to display: Number of items to display in ranking list
  • Filter: Filter for ranking list display (optional)
* You can check it by "view setting" on the administration menu, or at the URI with "p 12345678" at its end. (former Profile ID)

Originally, data aggregation needs to be determined aggregation methods by using technical terms such as "dimensions" and "metrics" (indicators). However, in this automatic step, the aggregation method is prescribed in advance.
  • Dimensions: ga:hostname, ga:pagePath, ga:pageTitle
  • Metrics: ga:pageviews, ga:sessions

It means if you do not find "Service Task Addon" that matches your aggregation policy, you need to create it separately. If there is someone with JavaScript knowledge in the company, it should be made in-house (by arranging existing Addon, etc.), but even if there isn't, you can get it in about one day when you make request to crowdsourcing, etc,

Reference) Dimensions & Metrics Explorer
Reference) API reference


Although setting of "filter" is optional item, various ranking aggregation becomes possible if you can master well.

For example, if you want ranking list by just "Blog posts in 2016 and 2017", set "ga:pagePath=~/2016/|/2017/". For another example, if you wish to tabulate the rankings with only "Featured articles" in 2017, set "ga:pagePath=~/2017/;ga:pageTitle=@[Feature]". (Advanced settings such as excluding Hall of Fame entries are also possible)
  • "=@" Matches part of the string
  • "!@" Does not match part of Character string
  • "=~" Contains regular expression match
  • "!~" Except when matching the following regular expression

In the era when the word "API economy" is called out, promoting various "automation / unmanned", it is nolonger a dream to shorten the reporting work of every week, for example, which took "15 minutes" to "one minute". Focusing on writing humorous "brief comment" using that saved time, it will raise the motivation of blog posters even more.

<OAuth 2.0 communication permission setting in advance>

1. Setting in Googlea Developers Console
Go to the Dashboard (https://console.developers.google.com/apis/dashboard) and enable "Google Analytics Reporting API" (not "Analytics API") and get "Client ID" and "Client secret".
  •  Name: (arbitrary, e.g. "q2analytics")
  •  Application type: Web application
  •  Approved JavaScript originator: (It is not necessary to set it)
  •  Authorized Redirect URI: https://s.questetra.net/oauth2callback

2. Communication setting of Questetra Workflow App
Configure [OAuth 2.0 Setting] and get the refresh token.
  •  Name: (arbitrary)
  •  Authorization Endpoint URL: https://accounts.google.com/o/oauth2/auth?Access_type=offline&approval_prompt=force (Google Standard)
  •  Token Endpoint URL: https://accounts.google.com/o/oauth2/token (Google Standard)
  •  Scope: https://www.googleapis.com/auth/analytics.readonly
  •  Client ID: (acquired at Google Developers Console)
  •  Consumer Secret: (acquired at Googlea Developers Console)
[Website Operation Report:"1. Report preparation" screen]


<Email Sample>

<Data Items list>


[Free Download]
<similar models>
<<related articles>>

[Japanese Entry (ε’Œζ–‡θ¨˜δΊ‹)]