Extended Google Analytics

Introduction

This plugin lets authorized users access the details of their Google Analytics accounts and retrieve their reports.

Prerequisites

You must have a Google developer account and Google Analytics account to use the plugin.
  1. You must create a project with OAuth authentication.
  1. You must create accounts on Google Analytics.

How to setup

I. How to create a project with OAuth

  1. Go to https://console.developers.google.com/.
  1. For the first time, select your country and accept the Terms of Service.
Image without caption
  1. Go to Select a project or current project, like in the images below. It will open a pop-up.
Image without caption
Image without caption
  1. In the opened pop-up, press the NEW PROJECT button.
Image without caption
  1. Set the Project name and press CREATE.
Image without caption
  1. After the project creation, select a created project and go to Select a project or current project, like in the images below. It will open a pop-up.
Image without caption
Image without caption
  1. In the opened pop-up, select created project.
Image without caption

Set up OAuth consent screen

  1. From the navigation menu select APIs & Services.
Image without caption
  1. From APIs & Services, select OAuth consent screen.
Image without caption
  1. Here, select External and press CREATE button.
Image without caption
  1. On OAuth consent screen step, complete all required fields then press SAVE AND CONTINUE button.
Image without caption
Image without caption
Image without caption
  1. On the Scopes step, press the SAVE AND CONTINUE button.
Image without caption
  1. On the Test users step, add your account to be able to test your app, then press SAVE AND CONTINUE button. Also, you can add more accounts for testing.
Image without caption
  1. On the Summary step, see added info and press BACK TO DASHBOARD.

Create credentials to access enabled APIs

  1. From APIs & Services, select Credentials.
Image without caption
  1. From the Credentials page, press CREATE CREDENTIALS button.
Image without caption
  1. Select OAuth client ID.
Image without caption
  1. Select Web application for the Application type option.
Image without caption
  1. Set up the Name option.
Image without caption
  1. Add Authorized redirect URIs and press CREATE.
Image without caption
You can get an authorized redirect URI from the plugin settings page.
Image without caption
Now you have App ID (Client ID) and App Secret (Client Secret).
Image without caption

Enable Google Analytics API and Google Analytics Reporting API

  1. From APIs & Services, select Library.
Image without caption
  1. Scroll down to Other category and select Google Analytics API.
Image without caption
  1. On opened page, press ENABLE button. It will open library page.
Image without caption
  1. Go back to the Google Analytics API library. Where you enable the library.
Image without caption
  1. Scroll down to More products to explore and select Google Analytics Reporting API.
Image without caption
  1. On the opened page, press ENABLE button. It will open library page.
Image without caption

II. How to create a Google Analytics account

For using this plugin you must have at least one Google Analytics account. If you don’t have one of these, follow the next steps to create one.
  1. Go to https://analytics.google.com/analytics.
  1. Press Start measuring.
Image without caption
  1. On the Account setup step, complete all fields and press the Next button.
  1. On the Property setup step, complete all fields.
  1. Press Show advanced options.
Image without caption
  1. ToggleΒ ONΒ Create a Universal Analytics property.
  1. Input the Website URL that you want to track, select Create both a Google Analytics 4 and a Universal Analytics property, and press the Next button.
Image without caption
  1. On the About your business step, complete info about your company and press Create.
  1. Accept Google Analytics Terms of Service Agreement.
  1. In the opened page, save MEASUREMENT ID (Gtag).
Image without caption
Now you have Gtag!
Also, you can find this Tag from Admin β†’ Account β†’ Property β†’ Data Streams after pressing on wished stream.
Image without caption
Image without caption
  1. To start collecting data from your websites, consult instructions from View tag instructions.
Image without caption
That is all, now you can use this plugin.

III. How to setup all keys in the plugin

Now, it is time to put all obtained keys in plugin settings.
  1. Go to the plugin settings page.
Image without caption
  1. Paste App ID and App Secret in plugin settings. These keys you obtained from the above section How to setup β†’ I. How to create a project with OAuth β†’ Create credentials to access enabled APIs on step 20.
Image without caption
  1. **Paste Gtag (headers) and Gtag in plugin settings. This key you obtained from the above section How to setup β†’ II. How to create a Google Analytics account on step 10.
Image without caption
☝
**Paste Gtag (headers) and Gtag in plugin settings if you want to collect analytics data from this Bubble app.

API Calls

Plugin Data Calls

  1. Get List of Account - Lists all accounts to which the user has access.
    1. Returns:
      Title
      Description
      Type
      kind
      Collection type. Value is β€œanalytics#accounts”.
      string
      username
      Email ID of the authenticated user
      string
      totalResults
      The total number of results for the query, regardless of the number of results in the response.
      number
      startIndex
      The starting index of the entries, which is 1 by default or otherwise specified by theΒ start-index Β query parameter.
      number
      itemsPerPage
      The maximum number of entries the response can contain, regardless of the actual number of entries returned. Its value ranges from 1 to 1000 with a value of 1000 by default, or otherwise specified by theΒ max-results Β query parameter.
      number
      previousLink
      Previous link for this account collection.
      string
      nextLink
      Next link for this account collection.
      string
      items[]
      A list of accounts.
      list
  1. Retrieve Reports - Gives you access to most of the report data in Google Analytics.
    1. Fields:
      Title
      Description
      Type
      end-date
      End date for fetching Analytics data. Request can specify an end date formatted asΒ YYYY-MM-DD , or as a relative date (e.g.,Β today ,Β yesterday , orΒ NdaysAgo Β whereΒ N Β is a positive integer).
      string
      ids
      The unique table ID of the form ga:XXXX, where XXXX is the Analytics view (profile) ID for which the query will retrieve the data.
      string
      start-date
      Start date for fetching Analytics data. Requests can specify a start date formatted asΒ YYYY-MM-DD , or as a relative date (e.g.,Β today ,Β yesterday , orΒ NdaysAgo Β whereΒ N Β is a positive integer).
      string
      metrics
      A list of comma-separated metrics, such asΒ ga:sessions,ga:bounces .
      string
      filters
      Dimension or metric filters that restrict the data returned for your request.
      string (optional)
      dimensions
      A list of comma-separated dimensions for your Analytics data, such asΒ ga:browser,ga:city .
      string (optional)
      sort
      A list of comma-separated dimensions and metrics indicating the sorting order and sorting direction for the returned data.
      string (optional)
      max-results
      The maximum number of rows to include in the response.
      number (optional)
      prettyPrint
      Returns response with indentations and line breaks. DefaultΒ false .
      string (optional)
      Returns:
      Title
      Description
      Type
      kind
      Resource type. Value is "analytics#gaData".
      string
      id
      An ID for this data response.
      string
      query
      This object contains all the values passed as parameters to the query. The meaning of each field is explained in the description of its correspondingΒ query parameter.
      object
      query.start-date
      Start date.
      string
      query.end-date
      End date.
      string
      query.ids
      Unique table ID.
      string
      query.metrics[]
      List of analytics metrics.
      list
      query.start-index
      Start index.
      number
      query.max-results
      Maximum results per page.
      number
      itemsPerPage
      The maximum number of rows the response can contain, regardless of the actual number of rows returned. If theΒ max-results Β query parameter is specified, the value ofΒ itemsPerPage Β is the smaller ofΒ max-results Β or 10,000. The default value ofΒ itemsPerPage Β is 1000.
      number
      totalResults
      The total number of rows in the query result, regardless of the number of rows returned in the response. For queries that result in a large number of rows,Β totalResults Β can be greater thanΒ itemsPerPage . SeeΒ Paging Β for more explanation ofΒ totalResults Β andΒ itemsPerPage Β for large queries.
      number
      selfLink
      Link to this page of results for this data query.
      string
      profileInfo
      Information about the view (profile) for which the data was requested. View (Profile) data is available through the Google Analytics Management API.
      object
      profileInfo.profileId
      View (Profile) ID, such asΒ 1174.
      string
      profileInfo.accountId
      Account ID to which this view (profile) belongs, such asΒ 30481.
      string
      profileInfo.webProfileId
      Web Property ID to which this view (profile) belongs, such asΒ UA-30481-1.
      string
      profileInfo.internalWebProfileId
      Internal ID for the web property to which this view (profile) belongs, such asΒ UA-30481-1.
      string
      profileInfo.profileName
      Name of the view (profile).
      string
      profileInfo.tableId
      Table ID for view (profile), consisting of "ga:" followed by the view (profile) ID.
      string
      containsSampledData
      True if the response containsΒ sampled Β data.
      boolean
      columnHeaders[]
      Column headers that list dimension names followed by the metric names. The order of dimensions and metrics is same as those specified in the request through theΒ metrics Β andΒ dimensions Β parameters. The number of headers is the number of dimensions + the number of metrics.
      list
      columnHeaders[].name
      Name of the dimension or metric.
      string
      columnHeaders[].columnType
      Column type. Either "DIMENSION" or "METRIC".
      string
      columnHeaders[].dataType
      Data type. Dimension column headers have onlyΒ STRING Β as data type. Metric column headers have data types for metric values such asΒ INTEGER,Β PERCENT,Β TIME,Β CURRENCY,Β FLOAT, etc. See theΒ metadata API responseΒ for all the possible data types.
      string
      totalsForAllResults
      Total values for the requested metrics as key-value pairs of metric names and values. The order of the metric totals is same as the metric order specified in the request.
      object
      totalsForAllResults.(key)
      Key-value pair for the total value of a metric. Key is the metric name and the value is the total value for that metric.
      string
      rows[]
      Analytics data rows, where each row contains a list of dimension values followed by the metric values. The order of dimensions and metrics is same as specified in the request. Each row has a list of N fields, where N = the number of dimensions + the number of metrics.
      list
  1. Real Time Data - Returns real-time data for a view (profile).
    1. Fields:
      Title
      Description
      Type
      ids
      Unique table ID for retrieving Analytics data. Table ID is of the form ga:XXXX, where XXXX is the Analytics view (profile) ID.
      string
      metrics
      A comma-separated list of Analytics metrics. E.g., 'rt:activeUsers'. At least one metric must be specified.
      string
      dimensions
      A comma-separated list of real-time dimensions. E.g., 'rt:medium,rt:city'.
      string (optional)
      filters
      A comma-separated list of dimension or metric filters to be applied to real-time data.
      string (optional)
      max-results
      The maximum number of entries to include in this feed.
      number (optional)
      sort
      A comma-separated list of dimensions or metrics that determine the sort order for real-time data.
      string (optional)
      Returns:
      Title
      Description
      Type
      kind
      Resource type.
      string
      id
      Unique ID for this data response.
      string
      query
      Real time data request query parameters.
      object
      query.ids
      Unique table ID.
      string
      query.dimensions
      List of real time dimensions.
      string
      query.metrics[]
      List of real time metrics.
      list
      query.sort[]
      List of dimensions or metrics based on which real time data is sorted.
      list
      query.filters
      Comma-separated list of dimension or metric filters.
      string
      query.max-results
      Maximum results per page.
      number
      totalResults
      The total number of rows for the query, regardless of the number of rows in the response.
      number
      selfLink
      Link to this page.
      string
      profileInfo
      Information for the view (profile), for which the real time data was requested.
      object
      profileInfo.profileId
      View (Profile) ID.
      string
      profileInfo.accountId
      Account ID to which this view (profile) belongs.
      string
      profileInfo.webPropertyId
      Web Property ID to which this view (profile) belongs.
      string
      profileInfo.internalWebPropertyId
      Internal ID for the web property to which this view (profile) belongs.
      string
      profileInfo.profileName
      View (Profile) name.
      string
      profileInfo.tableId
      Table ID for view (profile).
      string
      columnHeaders[]
      Column headers that list dimension names followed by the metric names. The order of dimensions and metrics is same as specified in the request.
      list
      columnHeaders[].name
      Column name.
      string
      columnHeaders[].columnType
      Column Type. Either DIMENSION or METRIC.
      string
      columnHeaders[].dataType
      Data type. Dimension column headers have only STRING as the data type. Metric column headers have data types for metric values such as INTEGER, DOUBLE, CURRENCY etc.
      string
      totalsForAllResults
      Total values for the requested metrics over all the results, not just the results returned in this response. The order of the metric totals is same as the metric order specified in the request.
      object
      totalsForAllResults.(key)
      Key-value pair for the total value of a metric. Key is the metric name and the value is the total value for that metric.
      string
      rows[]
      Real time data rows, where each row contains a list of dimension values followed by the metric values. The order of dimensions and metrics is same as specified in the request.
      list
  1. List Views - Lists views (profiles) to which the user has access.
    1. Fields:
      Title
      Description
      Type
      accountId
      Account ID for the view (profiles) to retrieve. Can either be a specific account ID or '~all', which refers to all the accounts to which the user has access.
      string
      webPropertyId
      Web property ID for the views (profiles) to retrieve. Can either be a specific web property ID or '~all', which refers to all the web properties to which the user has access.
      string
      Returns:
      Title
      Description
      Type
      kind
      Collection type. Value is "analytics#profiles".
      string
      username
      Email ID of the authenticated user
      string
      totalResults
      The total number of results for the query, regardless of the number of results in the response.
      number
      startIndex
      The starting index of the resources, which is 1 by default or otherwise specified by the start-index query parameter.
      number
      itemsPerPage
      The maximum number of resources the response can contain, regardless of the actual number of resources returned. Its value ranges from 1 to 1000 with a value of 1000 by default, or otherwise specified by the max-results query parameter.
      number
      previusLink
      Link to the previous page for this view (profile) collection.
      string
      nextLink
      Link to next page for this view (profile) collection.
      string
      items[]
      A list of views (profiles).
      list
  1. List webproperties - Lists properties to which the user has access.
    1. Fields:
      Title
      Description
      Type
      accountId
      Account ID to retrieve web properties. Can either be a specific account ID or '~all', which refers to all the accounts that the user has access.
      string
      Returns:
      Title
      Description
      Type
      kind
      Collection type. Value is "analytics#profiles".
      string
      username
      Email ID of the authenticated user
      string
      totalResults
      The total number of results for the query, regardless of the number of results in the response.
      number
      startIndex
      The starting index of the resources, which is 1 by default or otherwise specified by the start-index query parameter.
      number
      itemsPerPage
      The maximum number of resources the response can contain, regardless of the actual number of resources returned. Its value ranges from 1 to 1000 with a value of 1000 by default, or otherwise specified by the max-results query parameter.
      number
      previusLink
      Link to the previous page for this web property collection.
      string
      nextLink
      Link to next page for this web property collection.
      string
      items[]
      A list of web properties.
      list
  1. Get accounts info - Lists account summaries (lightweight tree comprised of accounts/properties/profiles) to which the user has access.
    1. Returns:
      Title
      Description
      Type
      kind
      Collection type.
      string
      username
      Email ID of the authenticated user
      string
      totalResults
      The total number of results for the query, regardless of the number of results in the response.
      number
      startIndex
      The starting index of the resources, which is 1 by default or otherwise specified by the start-index query parameter.
      number
      itemsPerPage
      The maximum number of resources the response can contain, regardless of the actual number of resources returned. Its value ranges from 1 to 1000 with a value of 1000 by default, or otherwise specified by the max-results query parameter.
      number
      previusLink
      Link to the previous page for this AccountSummary collection.
      string
      nextLink
      Link to next page for this AccountSummary collection.
      string
      items[]
      A list of AccountSummaries.
      list
  1. Retrieve Reports v4 - Returns the Analytics data.
    1. Fields:
      Title
      Description
      Type
      viewId
      The AnalyticsΒ view ID Β from which to retrieve data. EveryΒ ReportRequest Β within aΒ batchGet Β method must contain the sameΒ viewId.
      string
      Returns:
      Title
      Description
      Type
      reports[]
      Responses corresponding to each of the request.
      list

Plugin Action Calls

  1. Real Time Data (action) - Returns real-time data for a view (profile).
    1. Fields:
      Title
      Description
      Type
      ids
      Unique table ID for retrieving Analytics data. Table ID is of the form ga:XXXX, where XXXX is the Analytics view (profile) ID.
      string
      metrics
      A comma-separated list of Analytics metrics. E.g., 'rt:activeUsers'. At least one metric must be specified.
      string
      dimensions
      A comma-separated list of real-time dimensions. E.g., 'rt:medium,rt:city'.
      string (optional)
      filters
      A comma-separated list of dimension or metric filters to be applied to real-time data.
      string (optional)
      max-results
      The maximum number of entries to include in this feed.
      number (optional)
      sort
      A comma-separated list of dimensions or metrics that determine the sort order for real-time data.
      string (optional)
      Returns:
      Title
      Description
      Type
      kind
      Resource type.
      string
      id
      Unique ID for this data response.
      string
      query
      Real time data request query parameters.
      object
      query.ids
      Unique table ID.
      string
      query.dimensions
      List of real time dimensions.
      string
      query.metrics[]
      List of real time metrics.
      list
      query.sort[]
      List of dimensions or metrics based on which real time data is sorted.
      list
      query.filters
      Comma-separated list of dimension or metric filters.
      string
      query.max-results
      Maximum results per page.
      number
      totalResults
      The total number of rows for the query, regardless of the number of rows in the response.
      number
      selfLink
      Link to this page.
      string
      profileInfo
      Information for the view (profile), for which the real time data was requested.
      object
      profileInfo.profileId
      View (Profile) ID.
      string
      profileInfo.accountId
      Account ID to which this view (profile) belongs.
      string
      profileInfo.webPropertyId
      Web Property ID to which this view (profile) belongs.
      string
      profileInfo.internalWebPropertyId
      Internal ID for the web property to which this view (profile) belongs.
      string
      profileInfo.profileName
      View (Profile) name.
      string
      profileInfo.tableId
      Table ID for view (profile).
      string
      columnHeaders[]
      Column headers that list dimension names followed by the metric names. The order of dimensions and metrics is same as specified in the request.
      list
      columnHeaders[].name
      Column name.
      string
      columnHeaders[].columnType
      Column Type. Either DIMENSION or METRIC.
      string
      columnHeaders[].dataType
      Data type. Dimension column headers have only STRING as the data type. Metric column headers have data types for metric values such as INTEGER, DOUBLE, CURRENCY etc.
      string
      totalsForAllResults
      Total values for the requested metrics over all the results, not just the results returned in this response. The order of the metric totals is same as the metric order specified in the request.
      object
      totalsForAllResults.(key)
      Key-value pair for the total value of a metric. Key is the metric name and the value is the total value for that metric.
      string
      rows[]
      Real time data rows, where each row contains a list of dimension values followed by the metric values. The order of dimensions and metrics is same as specified in the request.
      list

Workflow example

Setup Authorization

In this workflow, it is represented how to add steps for authorization with Google Account.
  1. On the page, is placed an Authorization button.
Image without caption
  1. In the workflow, is created an event When Button Authorization is clicked with the following step.
Image without caption
  1. To add Signup/login with Google Analytics step is necessary:
    1. 3.1 To click on Click here to add an action… and select Signup with a social network.
      Image without caption
      3.2 In the opened pop-up, for OAuth provider option, select Google Analytics.
      Image without caption

Getting info about Google Analytics account

In this workflow, it is represented how data about Google Analytics accounts is shown.
  1. On the page, is placed a Dropdown element.
Image without caption
  1. In the workflow, is created an event When Dropdown’s value is changed with the following steps.
Image without caption
  1. The first step is necessary to clear the previous profileID if this exists.
Image without caption
  1. The second step is necessary to set accountID.
Image without caption
  1. The third step is necessary to set profileID. In account can be more profiles. Here is getting the first.
Image without caption
  1. This step is used to get data about user's activity.
Image without caption
  1. Obtained data from the previous step is saved.
Image without caption
  1. Getting Reports with version 3.
Image without caption
  1. Getting Reports with version 4.
Image without caption

How it looks on the page

Presented data on the page can be customized.
Image without caption

Changelogs

Update 08.09.17- Version 1.0.0
  • Initial Build
Update 19.09.17- Version 1.1.0
  • Updated Description
Update 26.02.18- Version 1.2.0
  • Updated Description
Update 10.05.18- Version 1.3.0
  • Added offline mode support and real-time reports
Update 13.05.18- Version 1.4.0
  • Minor improvements
Update 02.05.19- Version 1.5.0
  • Minor improvements
Update 02.05.19- Version 1.6.0
  • Minor improvements
Update 02.05.19- Version 1.7.0
  • Minor improvements
Update 22.10.20- Version 1.8.0
  • Updated credentials and API Call’s
Update 14.02.21- Version 1.9.0
  • Minor update
Update 09.06.21- Version 1.10.0
  • Added support for more metrics to api call β€œRetrieve Reports”
Update 15.07.21- Version 1.11.0
  • Updated icon
Update 29.07.22- Version 1.12.0
  • Added support for Google analytics v4
Update 08.11.22- Version 1.13.0
  • Added β€œid” parameter for β€œGoogle analytics v4”

Demo to preview the settings