Search code examples
google-analyticsgoogle-analytics-api

How to copy/export required GA4 events from one property to another


I have created one GA4 property (property-1) and one of our partner/vendor team creating another GA4 property (property-2). When we launch our vendor pages the events are getting tracked through Property-2.

Is there any way that to copy few/specific events from Property-2 to Property-1 without manual way. We are thinking like manually exporting the property-2 events to CSV from bigquery linking. Then import the events csv into Property-1, which seems manual process and not a feasible solution.


Solution

  • You can use The google analytics data api to extract from each property.

    POST https://analyticsdata.googleapis.com/v1beta/properties/GA4_PROPERTY_ID:runReport
      {
        "dateRanges": [{ "startDate": "2020-09-01", "endDate": "2020-09-15" }],
        "dimensions": [{ "name": "country" }],
        "metrics": [{ "name": "activeUsers" }]
      }
    

    This data is extracted in Json format so you will need to format it however you want in order to do your analytics.

    {
      "dimensionHeaders": [
        {
          "name": "country"
        }
      ],
      "metricHeaders": [
        {
          "name": "activeUsers",
          "type": "TYPE_INTEGER"
        }
      ],
      "rows": [
        {
          "dimensionValues": [
            {
              "value": "Japan"
            }
          ],
          "metricValues": [
            {
              "value": "2541"
            }
          ]
        },
        {
          "dimensionValues": [
            {
              "value": "France"
            }
          ],
          "metricValues": [
            {
              "value": "12"
            }
          ]
        }
      ],
      "metadata": {},
      "rowCount": 2
    }
    

    Note: At the time of writing the Google analytics data api is still in Beta. And may change in the future.

    This is a Beta version of the product. While no breaking changes are expected in this phase, pre-GA products may have limited support, and changes to pre-GA products may not be compatible with other pre-GA versions.