Description and usage of GoogleAnalytics processor:
Google Analytics is used to fetches the data from Google Analytics using its native support REST API(V3) and Private Key Path either JSON or P12 file.
Tags:
Syncfusion, Google, Analytics, GoogleAnalytics
Properties:
In the list below, the names of required properties appear in bold. Any other properties (not in bold) are considered optional. The table also indicates any default values.
Name |
Default Value |
Allowable Values |
Description |
JSON or P12 FilePath |
Enter the path of Private Key file Path either JSON or P12 file e.g. Drive:\TestFolder\keys.Json or keys.p12 | ||
ServiceAccount Mail-id |
Enter the ServiceAccount Mail-id | ||
Profile ID |
The unique ID used to retrieve the Analytics data. This ID is the concatenation of the namespace ga: with the Analytics view (profile) ID. You can retrieve the view (profile) ID by using the analytics.management.profiles.list method, which provides the id in the View (Profile) resource in the Google Analytics Management API. | ||
Start date |
* All Analytics data requests must specify a date range. * If you do not include start-date and end-date parameters in the request, the server returns an error. Date values can be for a specific date by using the pattern YYYY-MM-DD or relative by using today, yesterday, or the NdaysAgo pattern.Values must match [0-9]{4}-[0-9]{2}-[0-9]{2}|today|yesterday|[0-9]+(daysAgo). |
||
End date |
* If End Date is not mentioned today's date will be considered as End Date. * All Analytics data requests must specify a date range. If you do not include start-date and end-date parameters in the request, the server returns an error. Date values can be for a specific date by using the pattern YYYY-MM-DD or relative by using today, yesterday, or the NdaysAgo pattern.* Values must match [0-9]{4}-[0-9]{2}-[0-9]{2}|today|yesterday|[0-9]+(daysAgo). |
||
Metrics |
Enter the Metric details. The aggregated statistics for user activity to your site, such as clicks or pageviews. | ||
Dimensions | The dimensions parameter breaks down metrics by common criteria; for example, by ga:browser or ga:city. | ||
sort | A list of metrics and dimensions indicating the sorting order and sorting direction for the returned data. | ||
filters | The filters query string parameter restricts the data returned from your request. | ||
segment | Enter the segment details | ||
sampling level |
DEFAULT |
* DEFAULT * FASTER *HIGHER_PRECISION |
Use this parameter to set the sampling level (i.e. the number of sessions used to calculate the result) for a reporting query. If not supplied, the DEFAULT sampling level will be used. |
include-empty-rows |
true |
* true * false |
Defaults to true; if set to false, rows where all metric values are zero will be omitted from the response. |
start-index | Use this parameter as a pagination mechanism along with the max-results parameter for situations when totalResults exceeds 10,000 and you want to retrieve rows indexed at 10,001 and beyond. | ||
max-results | Maximum number of rows to include in the response. |
Relationships:
Name |
Description |
failure | All created FlowFiles are routed to this relationship |
success | All created FlowFiles are routed to this relationship |
Reads Attributes:
Name |
Description |
Not Specified | Not Specified |
Writes Attributes:
Name |
Description |
Not Specified | Not Specified |
How to create Google analytics account and add permission?
Summary
This processor collects the data about your blog/website and return it in JSON Format. To fetch the data about your websites/ blog must configure the Google analytics account with service account mail id and to set the permission for the account. Here are the steps to create account in Google analytics account and developer console.
Prerequisites:
-
Create the account with Google developer console.
-
Create the service account for your website.
-
Register the website in Google analytics account.
-
Add the permission for the service account.
Create the account with Google developer console:
-
Sign up with Google mail account (Gmail id username and password) to the Google Developer Console.
-
Then created the project and enabled the required API.
-
For example, you want to fetch data from Google analytics enable Analytics API as mandatory.
-
You can list out the enabled API’s in dashboard page.
Create the service account for your website:
-
Under IAM & admin panel select the service account. It is essential to create service account.
-
We can retrieve the data from the Google analytics only if we have OAuth credentials or service account keys. Service account key can be obtained in two ways. They are
-
P12 key file - private key get downloaded in encrypted form while creating service account.
-
JSON file - private key along with client id get downloaded in JSON format while creating service account.
-
-
To create service account key Credentials -> Manage service account (under OAuth 2.0 Client IDs) ->Create service account.
-
Enter the name of the service account and select the Furnish new private key.
-
It randomly generates the service account mail id. Note the mail id and keep it safely which can be used to retrieve the data.
-
Select the format of the file to which you want to download and keep it safely.
-
Now service account gets created.
Register the website in Google analytics account:
-
Then sign up with Google analytics account with Google mail account (Gmail id username and password) to the Google Analytics Account.
-
Under Admin tab create an account by giving account name, website name, website URL and click on get tracking id.
-
Now the account gets created for the specified URL.
Add the permission for the service account:
-
Add the service account mail id which can be generated while creating service account in the developer console window to the created account.
-
The steps followed to add service account mail ID to the created account,
-
From the admin panel of Google analytics account add the service account mail id under user management as shown in the image.
-
Add the mail id and set the permission limit for the created account.
-
Service account get added to analytics account and now data can be accessible with service account key.
-
Now you can fetch the data from Google analytics processor after configuring the processor.
Get value of profile ID in Google analytics account:
The Profile ID is taken from the analytics account by clicking the HOME option and copy the URL. In that URL select the 9 digits no from last between P and slash. Please refer the below image:
How to fetch data from Google analytics by using Data Integration Platform?
In Data Integration Platform use “GoogleAnalytics” Processor to fetch data from Google Analytics account. Here is the overview image for Google analytics processor.
Step 1: Drag “GoogleAnalytics” processor in canvas page and pair with success relationship. If data is sent to destination or queued successfully, moves into success relationship.
Step 2: You must fill the value of required properties appear in bold. Other properties (not in bold) are considered optional.
Step 3: Once job is success and it has able to fetch data from Google analytics, the relationship is fall into success.
Expected Output of the processor:
{
"ColumnHeaders": [{
"ColumnType": "DIMENSION",
"DataType": "STRING",
"Name": "ga:country"
}, {
"ColumnType": "METRIC",
"DataType": "INTEGER",
"Name": "ga:pageviews"
}],
"ContainsSampledData": false,
"DataTable": null,
"Id": "https://www.googleapis.com/analytics/v3/data/ga?ids=ga:120492920\u0026dimensions=ga:country\u0026metrics=ga:pageviews\u0026start-date=2016-01-01\u0026end-date=today\u0026start-index=1\u0026max-results=1000",
"ItemsPerPage": 1000,
"Kind": "analytics#gaData",
"NextLink": null,
"PreviousLink": null,
"ProfileInfo": {
"AccountId": "76559531",
"InternalWebPropertyId": "115259076",
"ProfileId": "120492920",
"ProfileName": "All Web Site Data",
"TableId": "ga:120492920",
"WebPropertyId": "UA-76559531-1"
},
"Query": {
"Dimensions": "ga:country",
"EndDate": "today",
"Filters": null,
"Ids": "ga:120492920",
"MaxResults": 1000,
"Metrics": ["ga:pageviews"],
"SamplingLevel": "DEFAULT",
"Segment": null,
"Sort": null,
"StartDate": "2016-01-01",
"StartIndex": 1
},
"Rows": [
["(not set)", "91"],
["Australia", "1"],
["Brazil", "19"],
["Cape Verde", "1"],
["China", "4"],
["Colombia", "1"],
["Ecuador", "1"],
["Egypt", "1"],
["Germany", "48"],
["Greece", "1"],
["India", "2272"],
["Indonesia", "1"],
["Iraq", "17"],
["Italy", "59"],
["Japan", "2"],
["Libya", "1"],
["Malaysia", "1"],
["Mexico", "2"],
["Netherlands", "2"],
["Norway", "1"],
["Pakistan", "1"],
["Peru", "1"],
["Philippines", "1"],
["Poland", "2"],
["Portugal", "3"],
["Russia", "307"],
["Saudi Arabia", "23"],
["South Africa", "1"],
["South Korea", "3"],
["Spain", "5"],
["Switzerland", "2"],
["Taiwan", "2"],
["Thailand", "22"],
["Ukraine", "2"],
["United Kingdom", "195"],
["United States", "658"]
],
"SampleSize": null,
"SampleSpace": null,
"SelfLink": "https://www.googleapis.com/analytics/v3/data/ga?ids=ga:120492920\u0026dimensions=ga:country\u0026metrics=ga:pageviews\u0026start-date=2016-01-01\u0026end-date=today\u0026start-index=1\u0026max-results=1000",
"TotalResults": 36,
"TotalsForAllResults": {
"ga:pageviews": "3754"
},
"ETag": "\"sP5LBgqDii7ksJERAgMB0CpTbRM/ZD1DtYvsvRYaFF0qr6z4Wcue9UI\""}