VCL.TAppAnalytics.TrackEvent

From RAD Studio Code Examples
Jump to: navigation, search

Description

This VCL code snippet shows how to track custom data by using the TrackEvent method of the TAppAnalytics component. In this example, there is a custom event to capture the application user's local timezone and the UTC offset.

The UTC offset is the difference in hours and minutes from Coordinated Universal Time (UTC) for a particular place and date.

The Onclick event handler for the TriggerEventButton button sends information to the server with the local time zone name and UTC offset value.

Code

Delphi code:

uses System.Analytics, System.Analytics.AppAnalytics, System.DateUtils;

procedure TForm1.ActiveButtonClick(Sender: TObject);
begin
  AppAnalytics1.Active := True;
end;

procedure TForm1.TriggerEventButtonClick(Sender: TObject);
begin
  AppAnalytics1.TrackEvent('Customer_Timezone', 'Recorded Locale with UTC Offset',
      TTimeZone.Local.DisplayName, TTimeZone.Local.UtcOffset.Hours);
end;

C++ code:

// Include the libraries in <project.h> 

#include <System.DateUtils.hpp>
#include <System.Analytics.AppAnalytics.hpp>

void __fastcall TForm1::ActiveButtonClick(TObject *Sender)
{
     AppAnalytics1->Active = True;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::TriggerEventButtonClick(TObject *Sender)
{
     AppAnalytics1->TrackEvent("Customer_Timezone", "Recorded Locale with UTC Offset", TTimeZone::Local->DisplayName, TTimeZone::Local->UtcOffset.Hours );
}

AppAnalytics Custom Events.png

Uses

See Also