Getting started with TMS FNC Cloud Google Analytics
Prerequisites
- TMS FNC Core installed and the runtime package added to the project.
- TMS FNC Cloud Pack installed.
- A Google Analytics account with a reporting view, and an OAuth 2.0 client (client ID and secret) created in the Google Cloud console.
Add the component
- Drop
TTMSFNCCloudGoogleAnalyticsonto a form or create it in code. - Set the OAuth credentials (
Authentication.ClientID,Authentication.Secret,Authentication.CallBackURL) and theViewIDto query. - Persist tokens and call
Connect; build a request and callRetrieveDataonceOnConnectedfires.
The minimal connect sequence — credentials, token persistence, and an
OnConnected handler that signals when it is safe to request data:
procedure TForm1.SetupAnalytics;
begin
FAnalytics := TTMSFNCCloudGoogleAnalytics.Create(Self);
// OAuth 2.0 client credentials from the Google Cloud console.
FAnalytics.Authentication.ClientID := '<your-client-id>.apps.googleusercontent.com';
FAnalytics.Authentication.Secret := '<your-client-secret>';
FAnalytics.Authentication.CallBackURL := 'http://127.0.0.1:8888';
// Persist the access and refresh tokens so the user is not asked to sign in every run.
FAnalytics.PersistTokens.Location := plIniFile;
FAnalytics.PersistTokens.Key := TTMSFNCUtils.AddBackslash(TTMSFNCUtils.GetDocumentsPath)
+ FAnalytics.ClassName + '.ini';
FAnalytics.LoadTokens;
// The reporting view (profile) every request targets.
FAnalytics.ViewID := '<your-view-id>';
FAnalytics.OnConnected := AnalyticsConnected;
// First run opens the browser for consent; later runs reuse the persisted tokens.
FAnalytics.Connect;
end;
procedure TForm1.AnalyticsConnected(Sender: TObject);
begin
// Tokens are valid here - it is now safe to build a request and call RetrieveData.
end;
Next steps
- Guides — authentication, building report requests, and reading results.
- API reference — full class reference.