0.0.20240503 • Published 15 days ago

@maxim_mazurok/gapi.client.analyticsadmin-v1beta v0.0.20240503

Weekly downloads
-
License
MIT
Repository
github
Last release
15 days ago

TypeScript typings for Google Analytics Admin API v1beta

Manage properties in Google Analytics. Warning: Creating multiple Customer Applications, Accounts, or Projects to simulate or act as a single Customer Application, Account, or Project (respectively) or to circumvent Service-specific usage limits or quotas is a direct violation of Google Cloud Platform Terms of Service as well as Google APIs Terms of Service. These actions can result in immediate termination of your GCP project(s) without any warning. For detailed description please check documentation.

Installing

Install typings for Google Analytics Admin API:

npm install @types/gapi.client.analyticsadmin-v1beta --save-dev

Usage

You need to initialize Google API client in your code:

gapi.load('client', () => {
  // now we can use gapi.client
  // ...
});

Then load api client wrapper:

gapi.client.load(
  'https://analyticsadmin.googleapis.com/$discovery/rest?version=v1beta',
  () => {
    // now we can use:
    // gapi.client.analyticsadmin
  }
);
// Deprecated, use discovery document URL, see https://github.com/google/google-api-javascript-client/blob/master/docs/reference.md#----gapiclientloadname----version----callback--
gapi.client.load('analyticsadmin', 'v1beta', () => {
  // now we can use:
  // gapi.client.analyticsadmin
});

Don't forget to authenticate your client before sending any request to resources:

// declare client_id registered in Google Developers Console
var client_id = '',
  scope = [
    // Edit Google Analytics management entities
    'https://www.googleapis.com/auth/analytics.edit',

    // See and download your Google Analytics data
    'https://www.googleapis.com/auth/analytics.readonly',
  ],
  immediate = true;
// ...

gapi.auth.authorize(
  {client_id: client_id, scope: scope, immediate: immediate},
  authResult => {
    if (authResult && !authResult.error) {
      /* handle successful authorization */
    } else {
      /* handle authorization error */
    }
  }
);

After that you can use Google Analytics Admin API resources:

/*
Marks target Account as soft-deleted (ie: "trashed") and returns it. This API does not have a method to restore soft-deleted accounts. However, they can be restored using the Trash Can UI. If the accounts are not restored before the expiration time, the account and all child resources (eg: Properties, GoogleAdsLinks, Streams, AccessBindings) will be permanently purged. https://support.google.com/analytics/answer/6154772 Returns an error if the target is not found.
*/
await gapi.client.analyticsadmin.accounts.delete({name: 'name'});

/*
Lookup for a single Account.
*/
await gapi.client.analyticsadmin.accounts.get({name: 'name'});

/*
Get data sharing settings on an account. Data sharing settings are singletons.
*/
await gapi.client.analyticsadmin.accounts.getDataSharingSettings({
  name: 'name',
});

/*
Returns all accounts accessible by the caller. Note that these accounts might not currently have GA4 properties. Soft-deleted (ie: "trashed") accounts are excluded by default. Returns an empty list if no relevant accounts are found.
*/
await gapi.client.analyticsadmin.accounts.list({});

/*
Updates an account.
*/
await gapi.client.analyticsadmin.accounts.patch({name: 'name'});

/*
Requests a ticket for creating an account.
*/
await gapi.client.analyticsadmin.accounts.provisionAccountTicket({});

/*
Returns a customized report of data access records. The report provides records of each time a user reads Google Analytics reporting data. Access records are retained for up to 2 years. Data Access Reports can be requested for a property. Reports may be requested for any property, but dimensions that aren't related to quota can only be requested on Google Analytics 360 properties. This method is only available to Administrators. These data access records include GA4 UI Reporting, GA4 UI Explorations, GA4 Data API, and other products like Firebase & Admob that can retrieve data from Google Analytics through a linkage. These records don't include property configuration changes like adding a stream or changing a property's time zone. For configuration change history, see [searchChangeHistoryEvents](https://developers.google.com/analytics/devguides/config/admin/v1/rest/v1alpha/accounts/searchChangeHistoryEvents).
*/
await gapi.client.analyticsadmin.accounts.runAccessReport({entity: 'entity'});

/*
Searches through all changes to an account or its children given the specified set of filters.
*/
await gapi.client.analyticsadmin.accounts.searchChangeHistoryEvents({
  account: 'account',
});

/*
Returns summaries of all accounts accessible by the caller.
*/
await gapi.client.analyticsadmin.accountSummaries.list({});

/*
Acknowledges the terms of user data collection for the specified property. This acknowledgement must be completed (either in the Google Analytics UI or through this API) before MeasurementProtocolSecret resources may be created.
*/
await gapi.client.analyticsadmin.properties.acknowledgeUserDataCollection({
  property: 'property',
});

/*
Creates an "GA4" property with the specified location and attributes.
*/
await gapi.client.analyticsadmin.properties.create({});

/*
Marks target Property as soft-deleted (ie: "trashed") and returns it. This API does not have a method to restore soft-deleted properties. However, they can be restored using the Trash Can UI. If the properties are not restored before the expiration time, the Property and all child resources (eg: GoogleAdsLinks, Streams, AccessBindings) will be permanently purged. https://support.google.com/analytics/answer/6154772 Returns an error if the target is not found, or is not a GA4 Property.
*/
await gapi.client.analyticsadmin.properties.delete({name: 'name'});

/*
Lookup for a single "GA4" Property.
*/
await gapi.client.analyticsadmin.properties.get({name: 'name'});

/*
Returns the singleton data retention settings for this property.
*/
await gapi.client.analyticsadmin.properties.getDataRetentionSettings({
  name: 'name',
});

/*
Returns child Properties under the specified parent Account. Only "GA4" properties will be returned. Properties will be excluded if the caller does not have access. Soft-deleted (ie: "trashed") properties are excluded by default. Returns an empty list if no relevant properties are found.
*/
await gapi.client.analyticsadmin.properties.list({});

/*
Updates a property.
*/
await gapi.client.analyticsadmin.properties.patch({name: 'name'});

/*
Returns a customized report of data access records. The report provides records of each time a user reads Google Analytics reporting data. Access records are retained for up to 2 years. Data Access Reports can be requested for a property. Reports may be requested for any property, but dimensions that aren't related to quota can only be requested on Google Analytics 360 properties. This method is only available to Administrators. These data access records include GA4 UI Reporting, GA4 UI Explorations, GA4 Data API, and other products like Firebase & Admob that can retrieve data from Google Analytics through a linkage. These records don't include property configuration changes like adding a stream or changing a property's time zone. For configuration change history, see [searchChangeHistoryEvents](https://developers.google.com/analytics/devguides/config/admin/v1/rest/v1alpha/accounts/searchChangeHistoryEvents).
*/
await gapi.client.analyticsadmin.properties.runAccessReport({entity: 'entity'});

/*
Updates the singleton data retention settings for this property.
*/
await gapi.client.analyticsadmin.properties.updateDataRetentionSettings({
  name: 'name',
});
0.0.20240503

15 days ago

0.0.20240501

19 days ago

0.0.20240430

20 days ago

0.0.20240429

21 days ago

0.0.20240427

22 days ago

0.0.20240424

26 days ago

0.0.20240423

27 days ago

0.0.20240422

28 days ago

0.0.20240420

29 days ago

0.0.20240417

1 month ago

0.0.20240415

1 month ago

0.0.20240412

1 month ago

0.0.20240409

1 month ago

0.0.20240405

1 month ago

0.0.20240403

2 months ago

0.0.20240402

2 months ago

0.0.20240401

2 months ago

0.0.20240329

2 months ago

0.0.20240328

2 months ago

0.0.20240326

2 months ago

0.0.20240322

2 months ago

0.0.20240320

2 months ago

0.0.20240319

2 months ago

0.0.20240318

2 months ago

0.0.20240317

2 months ago

0.0.20240312

2 months ago

0.0.20240306

2 months ago

0.0.20240305

3 months ago

0.0.20240304

3 months ago

0.0.20240303

3 months ago

0.0.20240226

3 months ago

0.0.20240227

3 months ago

0.0.20240225

3 months ago

0.0.20240220

3 months ago

0.0.20240221

3 months ago

0.0.20240219

3 months ago

0.0.20240213

3 months ago

0.0.20240211

3 months ago

0.0.20240207

3 months ago

0.0.20240206

3 months ago

0.0.20240204

4 months ago

0.0.20240131

4 months ago

0.0.20240130

4 months ago

0.0.20240126

4 months ago

0.0.20240123

4 months ago

0.0.20240119

4 months ago

0.0.20240115

4 months ago

0.0.20240110

4 months ago

0.0.20240109

4 months ago

0.0.20240105

4 months ago

0.0.20240103

5 months ago

0.0.20240102

5 months ago

0.0.20231212

5 months ago

0.0.20231210

5 months ago

0.0.20231205

6 months ago

0.0.20231204

6 months ago

0.0.20231203

6 months ago

0.0.20231128

6 months ago

0.0.20230817

9 months ago

0.0.20231106

7 months ago

0.0.20230810

9 months ago

0.0.20231105

7 months ago

0.0.20231108

6 months ago

0.0.20231107

6 months ago

0.0.20230814

9 months ago

0.0.20230815

9 months ago

0.0.20231113

6 months ago

0.0.20231112

6 months ago

0.0.20231114

6 months ago

0.0.20230808

10 months ago

0.0.20230926

8 months ago

0.0.20230927

8 months ago

0.0.20230806

10 months ago

0.0.20230809

10 months ago

0.0.20230920

8 months ago

0.0.20230803

10 months ago

0.0.20230801

10 months ago

0.0.20230923

8 months ago

0.0.20230802

10 months ago

0.0.20231101

7 months ago

0.0.20230719

10 months ago

0.0.20230718

10 months ago

0.0.20230711

10 months ago

0.0.20231127

6 months ago

0.0.20231006

7 months ago

0.0.20230712

10 months ago

0.0.20230830

9 months ago

0.0.20230831

9 months ago

0.0.20230716

10 months ago

0.0.20230713

10 months ago

0.0.20231011

7 months ago

0.0.20231015

7 months ago

0.0.20230829

9 months ago

0.0.20230708

11 months ago

0.0.20230706

11 months ago

0.0.20230821

9 months ago

0.0.20230822

9 months ago

0.0.20230825

9 months ago

0.0.20230704

11 months ago

0.0.20230823

9 months ago

0.0.20230824

9 months ago

0.0.20231001

8 months ago

0.0.20231003

8 months ago

0.0.20231002

8 months ago

0.0.20231004

8 months ago

0.0.20230731

10 months ago

0.0.20231031

7 months ago

0.0.20231030

7 months ago

0.0.20231018

7 months ago

0.0.20231017

7 months ago

0.0.20230723

10 months ago

0.0.20230720

10 months ago

0.0.20230726

10 months ago

0.0.20230727

10 months ago

0.0.20230724

10 months ago

0.0.20231023

7 months ago

0.0.20231022

7 months ago

0.0.20231025

7 months ago

0.0.20231024

7 months ago

0.0.20231027

7 months ago

0.0.20230917

8 months ago

0.0.20230919

8 months ago

0.0.20230910

8 months ago

0.0.20230913

8 months ago

0.0.20230911

8 months ago

0.0.20230912

8 months ago

0.0.20230906

9 months ago

0.0.20230629

11 months ago

0.0.20230628

11 months ago

0.0.20230901

9 months ago

0.0.20230627

11 months ago

0.0.20230626

11 months ago

0.0.20230612

11 months ago

0.0.20230613

11 months ago

0.0.20230614

11 months ago

0.0.20230615

11 months ago

0.0.20230620

11 months ago

0.0.20230607

12 months ago

0.0.20230608

12 months ago

0.0.20230601

12 months ago

0.0.20230524

12 months ago

0.0.20230523

12 months ago

0.0.20230605

12 months ago

0.0.20230606

12 months ago

0.0.20230531

12 months ago

0.0.20230530

12 months ago

0.0.20230511

1 year ago

0.0.20230517

1 year ago

0.0.20230518

1 year ago

0.0.20230515

1 year ago

0.0.20230516

1 year ago

0.0.20230521

12 months ago

0.0.20230509

1 year ago

0.0.20230502

1 year ago

0.0.20230503

1 year ago

0.0.20230621

11 months ago

0.0.20230622

11 months ago

0.0.20230429

1 year ago

0.0.20230507

1 year ago

0.0.20230504

1 year ago

0.0.20230510

1 year ago

0.0.20230412

1 year ago

0.0.20230413

1 year ago

0.0.20230418

1 year ago

0.0.20230419

1 year ago

0.0.20230416

1 year ago

0.0.20230301

1 year ago

0.0.20230420

1 year ago

0.0.20230326

1 year ago

0.0.20230404

1 year ago

0.0.20230402

1 year ago

0.0.20230405

1 year ago

0.0.20230328

1 year ago

0.0.20230406

1 year ago

0.0.20230329

1 year ago

0.0.20230330

1 year ago

0.0.20230410

1 year ago

0.0.20230411

1 year ago

0.0.20230315

1 year ago

0.0.20230316

1 year ago

0.0.20230314

1 year ago

0.0.20230319

1 year ago

0.0.20230322

1 year ago

0.0.20230323

1 year ago

0.0.20230321

1 year ago

0.0.20230425

1 year ago

0.0.20230304

1 year ago

0.0.20230228

1 year ago

0.0.20230302

1 year ago

0.0.20230424

1 year ago

0.0.20230226

1 year ago

0.0.20230308

1 year ago

0.0.20230309

1 year ago

0.0.20230427

1 year ago

0.0.20230307

1 year ago

0.0.20230216

1 year ago

0.0.20230214

1 year ago

0.0.20230215

1 year ago

0.0.20230223

1 year ago

0.0.20230201

1 year ago

0.0.20230202

1 year ago

0.0.20230221

1 year ago

0.0.20230222

1 year ago

0.0.20230129

1 year ago

0.0.20230203

1 year ago

0.0.20230131

1 year ago

0.0.20230212

1 year ago

0.0.20230126

1 year ago

0.0.20230125

1 year ago

0.0.20230124

1 year ago

0.0.20230123

1 year ago

0.0.20230119

1 year ago

0.0.20230118

1 year ago

0.0.20230117

1 year ago

0.0.20230112

1 year ago

0.0.20230111

1 year ago

0.0.20230110

1 year ago

0.0.20230109

1 year ago

0.0.20230105

1 year ago