Create account through google analytics v4 admin API

Viewed 62

I need to create g4 analytics accounts at scale.

I made a call to the API according to the docs:

apiClient.request({
      method: "POST",
      url: "https://analyticsadmin.googleapis.com/v1alpha/accounts:provisionAccountTicket",
      data: {
        account: {
          displayName: "Test Account",
          regionCode: "US",
        },
        redirectUri: "https://my-redirect-url",
      },
    }),

And I got this response:

{ accountTicketId: "4iR-Ogm8RDSMoV3lQpjZjQ" }

How do I proceed here? What's the next step?

2 Answers

As per account provsioning.

This method returns the accountTicketId field that should be included in the Terms of Service (TOS) URL: https://analytics.google.com/analytics/web/?provisioningSignup=false#/termsofservice/ACCOUNT_TICKET_ID. Once a user visits the TOS URL and accepts the Terms of Service, creation of a Google Analytics account will be complete (Account provisioning sample).

So the next step would be to have the user visit the page listed and approve the TOS.

As per previous comment and as it is mentioned in the Google's api documentation

request = {
          account,
          redirectUri
          };
          const newAc = await analyticsAdminClient.provisionAccountTicket(request);
          console.log(`https://analytics.google.com/analytics/web/?provisioningSignup=false#/termsofservice/${newAc[0].accountTicketId}`);

Console statement from above url will take you to Google's TOC page, just accept the T&C and you are done. Account will be created.

Related