Search code examples
google-analyticsanalyticsgoogle-analytics-apigoogle-analytics-firebaseacquisition

How do you get data from google analytics -v4 for acquisitions - campaigns?


Can someone give an example of the query to be used?How do we access the acquisitions and then campaign data from that ?


Solution

  • The simplest method would be to make an Analytics Reporting API V4 request with the ga:newusers metric and the ga:source, ga:medium, ga:campaign.

    POST https://analyticsreporting.googleapis.com/v4/reports:batchGet
    {
      "reportRequests": 
      [
        {
          "viewId": "1174",
          "dateRanges": 
          [
            {
              "startDate": "2014-11-01",
              "endDate": "2014-11-30"
            }
          ],
          "metrics": 
          [
            {
              "expression": "ga:newusers"
            }
          ],
          "dimensions": 
          [
            {
              "name": "ga:campaign"
            },
            {
              "name": "ga:source"
            },
            {
              "name": "ga:medium"
            }
          ]
        }
      ]
    }
    

    And again in the API Explorer.

    The API also allows you to construct a cohort request to measure engagement overtime.

    If you are new to Google's APIs, they make available many client libraries as well as set of quickstart guides.