0.0.20240503 • Published 15 days ago

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

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

TypeScript typings for Google Analytics Admin API v1alpha

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-v1alpha --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=v1alpha',
  () => {
    // 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', 'v1alpha', () => {
  // 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',

    // Manage Google Analytics Account users by email address
    'https://www.googleapis.com/auth/analytics.manage.users',

    // View Google Analytics user permissions
    'https://www.googleapis.com/auth/analytics.manage.users.readonly',

    // 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({});

/*
Creates a connected site tag for a Universal Analytics property. You can create a maximum of 20 connected site tags per property. Note: This API cannot be used on GA4 properties.
*/
await gapi.client.analyticsadmin.properties.createConnectedSiteTag({});

/*
Create a roll-up property and all roll-up property source links.
*/
await gapi.client.analyticsadmin.properties.createRollupProperty({});

/*
Create a subproperty and a subproperty event filter that applies to the created subproperty.
*/
await gapi.client.analyticsadmin.properties.createSubproperty({});

/*
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'});

/*
Deletes a connected site tag for a Universal Analytics property. Note: this has no effect on GA4 properties.
*/
await gapi.client.analyticsadmin.properties.deleteConnectedSiteTag({});

/*
Fetches the opt out status for the automated GA4 setup process for a UA property. Note: this has no effect on GA4 property.
*/
await gapi.client.analyticsadmin.properties.fetchAutomatedGa4ConfigurationOptOut(
  {}
);

/*
Given a specified UA property, looks up the GA4 property connected to it. Note: this cannot be used with GA4 properties.
*/
await gapi.client.analyticsadmin.properties.fetchConnectedGa4Property({});

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

/*
Lookup for a AttributionSettings singleton.
*/
await gapi.client.analyticsadmin.properties.getAttributionSettings({
  name: 'name',
});

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

/*
Lookup for Google Signals settings for a property.
*/
await gapi.client.analyticsadmin.properties.getGoogleSignalsSettings({
  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({});

/*
Lists the connected site tags for a Universal Analytics property. A maximum of 20 connected site tags will be returned. Note: this has no effect on GA4 property.
*/
await gapi.client.analyticsadmin.properties.listConnectedSiteTags({});

/*
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'});

/*
Sets the opt out status for the automated GA4 setup process for a UA property. Note: this has no effect on GA4 property.
*/
await gapi.client.analyticsadmin.properties.setAutomatedGa4ConfigurationOptOut(
  {}
);

/*
Updates attribution settings on a property.
*/
await gapi.client.analyticsadmin.properties.updateAttributionSettings({
  name: 'name',
});

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

/*
Updates Google Signals settings for a property.
*/
await gapi.client.analyticsadmin.properties.updateGoogleSignalsSettings({
  name: 'name',
});
0.0.20240503

15 days ago

0.0.20240501

18 days ago

0.0.20240430

19 days ago

0.0.20240429

20 days ago

0.0.20240427

21 days ago

0.0.20240424

25 days ago

0.0.20240423

26 days ago

0.0.20240422

27 days ago

0.0.20240420

28 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.20230629

11 months ago

0.0.20230628

11 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.20230901

9 months ago

0.0.20230627

11 months ago

0.0.20230626

11 months ago

0.0.20230524

12 months ago

0.0.20230523

12 months ago

0.0.20230531

12 months ago

0.0.20230530

12 months ago

0.0.20230429

1 year 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.20230605

12 months ago

0.0.20230606

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.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.20230404

1 year ago

0.0.20230402

1 year ago

0.0.20230405

1 year ago

0.0.20230406

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.20230302

1 year ago

0.0.20230424

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.20230326

1 year ago

0.0.20230328

1 year ago

0.0.20230329

1 year ago

0.0.20230330

1 year ago

0.0.20230228

1 year ago

0.0.20230226

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.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.20230201

1 year ago

0.0.20230202

1 year ago

0.0.20221116

2 years ago

0.0.20221115

2 years ago

0.0.20221114

2 years ago

0.0.20221110

2 years ago

0.0.20221109

2 years ago

0.0.20221108

2 years ago

0.0.20221107

2 years ago

0.0.20230126

1 year ago

0.0.20230117

1 year ago

0.0.20230118

1 year ago

0.0.20221214

1 year ago

0.0.20221213

1 year ago

0.0.20221212

1 year ago

0.0.20230119

1 year ago

0.0.20230124

1 year ago

0.0.20221208

1 year ago

0.0.20230125

1 year ago

0.0.20221207

1 year ago

0.0.20221206

1 year ago

0.0.20221129

1 year ago

0.0.20230123

1 year ago

0.0.20221205

1 year ago

0.0.20230104

1 year ago

0.0.20230105

1 year ago

0.0.20221201

1 year ago

0.0.20230109

1 year ago

0.0.20230110

1 year ago

0.0.20230111

1 year ago

0.0.20230112

1 year ago

0.0.20221031

2 years ago

0.0.20221017

2 years ago

0.0.20221013

2 years ago

0.0.20221012

2 years ago

0.0.20221011

2 years ago

0.0.20221010

2 years ago

0.0.20221020

2 years ago

0.0.20221006

2 years ago

0.0.20221027

2 years ago

0.0.20221005

2 years ago

0.0.20221103

2 years ago

0.0.20221026

2 years ago

0.0.20221004

2 years ago

0.0.20221102

2 years ago

0.0.20221025

2 years ago

0.0.20221003

2 years ago

0.0.20221101

2 years ago

0.0.20221024

2 years ago

0.0.20220928

2 years ago

0.0.20220929

2 years ago

0.0.20221019

2 years ago

0.0.20221018

2 years ago

0.0.20220830

2 years ago

0.0.20220916

2 years ago

0.0.20220906

2 years ago

0.0.20220829

2 years ago

0.0.20220819

2 years ago

0.0.20220908

2 years ago

0.0.20220831

2 years ago

0.0.20220920

2 years ago

0.0.20220921

2 years ago

0.0.20220910

2 years ago

0.0.20220823

2 years ago

0.0.20220912

2 years ago

0.0.20220824

2 years ago

0.0.20220913

2 years ago

0.0.20220825

2 years ago

0.0.20220826

2 years ago

0.0.20220926

2 years ago

0.0.20220915

2 years ago

0.0.20220904

2 years ago

0.0.20220817

2 years ago

0.0.20220812

2 years ago

0.0.20220810

2 years ago