How to generate Google Analytics tracking code programmatic-ally?
I am new to Google Analytics API, can someone please help
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.
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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With