Articles in this section
Category / Section

Working with Google Analytics Processor

4 mins read

Summary

Data Integration GoogleAnalytics processor collects the data about your blog/website and return it in JSON Format. To fetch the data about your websites/ blog, you must configure the Google analytics account with service account mail id and should set the permission for the account. The steps to create account in Google analytics account and developer console is given below.

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

Step 1: Sign up with Google mail account (Gmail username and password) to the Google Developer Console.

Step 2: Then create the project and enable the required API.

For example, if you want to fetch data from Google analytics, it is mandatory to enable analytics API (Application Program Interface)

https://help.syncfusion.com/data-integration/processors/GoogleAnalytics_images/GoogleAnalytics_img1.jpeg

  • You can list out the enabled APIs in dashboard page.

https://help.syncfusion.com/data-integration/processors/GoogleAnalytics_images/GoogleAnalytics_img2.jpeg

Create the service account for your website:

Step 1: Under IAM and admin panel select the service account. It is essential to create service account.

https://help.syncfusion.com/data-integration/processors/GoogleAnalytics_images/GoogleAnalytics_img3.jpeg

Step 2: 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 is downloaded in encrypted form while creating service account.
  • JSON file: private key along with client id gets downloaded in JSON format while creating service account.

Step 3: To create service account key credentials -> Manage service account (under OAuth 2.0 Client IDs) ->Create service account.

https://help.syncfusion.com/data-integration/processors/GoogleAnalytics_images/GoogleAnalytics_img4.jpeg

 

Step 4: Enter the name of the service account and select the furnish new private key.Select, the format of the file that you want to download and keep  safely.-

 

Create Service Account

  •  Now, service account is created. It randomly generates the service account mails. Note the mails, and keep it safely, which can be used to retrieve the data.

Register the website in Google analytics account:

Step 1: Then sign up with Google analytics account with Google mail account (Gmail id username and password) to the Google Analytics Account.

Step 2: Under Admin tab create an account by giving account name, website name, website URL and click on get tracking id.

Create Service Account

  • Now the account gets created for the specified URL.

Add the permission for the service account:

Add the service account mail, which can be generated while creating service account in the developer console window to the created account. The following are the steps required to add service account mail to the created account:

Step 1: From the admin panel of Google analytics account, add the service account mail under user management as shown in the image.

https://help.syncfusion.com/data-integration/processors/GoogleAnalytics_images/GoogleAnalytics_img7.jpg

Step2: Add the mail and set the permission limit for the created account.

https://help.syncfusion.com/data-integration/processors/GoogleAnalytics_images/GoogleAnalytics_img8.jpeg

  • Service account is 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 the value of profile ID in Google analytics account:

The Profile ID is taken from the analytics account by clicking HOME option and copying the URL. In that URL select the nine digits number from last between P and slash. Please refer to the following image:

https://help.syncfusion.com/data-integration/processors/GoogleAnalytics_images/GoogleAnalytics_img9.jpg

 

Data Integration flow to fetch the data from Google analytics account.

In Data Integration Platform use “GoogleAnalytics” Processor to fetch data from Google Analytics account. Here is the overview image for Google analytics data integration template which gets the input data from google analytics account, process the data, convert into json and finally move the json data into Microsoft SQL server.

 

List of processors used in this sample:

 

Processor

Comments

Get File

Fetches data from Google analytics.

SplitJson

Splits the json data.

ReplaceText

Modifies the Json data.

ExtractText

Extracts the data and save it in the attribute.

ReplaceText

Frames flat json data.

ConvertJSONToSQL

Frames SQL query from the json data.

PutSQL

Executes the SQL query and put the value into the table.

PublishDataSource

Publishes the data into the dashboard.

 

Overview:

 

 

Steps to Configure the Data Integration Processor:

 

Step 1: Drag “GoogleAnalytics” processor in canvas page and configure the required properties.

  • You must fill the value of required properties appears in bold. Other properties (not in bold) are considered optional.

https://help.syncfusion.com/data-integration/processors/GoogleAnalytics_images/GoogleAnalytics_imge12.jpeg

Step 2:  Add SplitJson processor and add connection from GoogleAnalytics to SplitJson with Success relationship. It splits the input json data.

  • Configure the JsonPath Expression property of the SplitJson processor to split the json array.

Step 3: Add ReplaceText processor and add connection from SplitJson processor to ReplaceText processor with split relationship.

  • Configure the Search Value and Replacement Value property with regex expression to remove the “,[,] from the json data.

Step 4: Add ExtractText processor and add connection from ReplaceText processor to ExtractText processor with Success relationship.

 

  • Configure the processor and add new attribute named as “inputdata” to extract the input data and to save the data into the attribute.

 

Step 5:  Add ReplaceText processor and add connection from ExtractText processor to ReplaceText processor with matched relationship.

  • Using expression language, configure the Replacement Value property of the ReplaceText processor to frame the flat json data with the inputdata attribute.

Expression: {"Country":"${inputdata:getDelimitedField(1)}","Pageviews":${inputdata:getDelimitedField(2)}}

Step 6: Add ConvertJSONToSQL processor and add connection from ReplaceText processor to ConvertJSONToSQL processor with Success relationship.

  • Configure the JDBC Connection Pool, Statement Type, and Table Name properties of the ConvertJSONToSQL processor.

 

 

Step 7: Add PutSQL processor and add connection from ConvertJSONToSQL processor to PutSQL processor with Sql relationship.

  • Mention the JDBC connection pool name in the JDBC Connection Pool property of the PutSQL processor.

Step 8: Add PublishDataSource processor and add connection from PutSQL processor to PublishDataSource processor with Success relationship.

  • Mention the database connection and the table name in the Connection Type, Database Connection Pooling Service, and Table Name properties of the PublishDataSource processor.
  • It publishes the data source in the Syncfusion Dashboard Designer and can create dashboard view with the fetched data in the Dashboard Desinger.

View the data in Syncfusion Dashboard Designer

Refer to the Import data source to designer. Import the data source from data integration server into designer, and create useful view in the designer to evaluate the data.

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied