Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I generate a GA tracking code programmatically?

How to generate Google Analytics tracking code programmatic-ally?

I am new to Google Analytics API, can someone please help

like image 714
I-M-JM Avatar asked Mar 28 '11 05:03

I-M-JM


People also ask

How do I set up tracking codes in Google Analytics?

Step-1: Navigate to your Google Analytics account and click on 'Admin'. Step-2: Click on 'Tracking Info' and then on 'Tracking code'. Step-3: Now copy the 'Global Site Tag' script, then open Notepad on your PC and paste the code in the text file. Step-4: Now save the file with the name 'analyticstracking.


2 Answers

It is NOT possible to create new Google Analytics accounts or profiles programmatically using the existing APIs.

There are two APIs available, the Data Export API and the Management API. However, they are bot read-only.

With the Google Analytics Data Export API, you can develop client applications to request data from an existing Analytics profile for an authorized user, and refine the results of the request using query parameters. Currently, the Data Export API supports read-only access to your Google Analytics data.

 

Currently, the Management API supports read-only access to five components of the Google Analytics Management system: Account data,Profile data, Web property data, Goal data, Advanced segments

like image 160
Ciaran Avatar answered Jan 02 '23 16:01

Ciaran


Seems like it's finally possible in 2021 with alpha api.

https://developers.google.com/analytics/devguides/config/admin/v1/rest/v1alpha/properties/create#authorization-scopes

like image 37
Arkadiusz 'flies' Rzadkowolski Avatar answered Jan 02 '23 15:01

Arkadiusz 'flies' Rzadkowolski