Track your Delphi/Pascal GUI application with Google Analytics » Developer.Team - Developers Paradise!

Track your Delphi/Pascal GUI application with Google Analytics

Track your Delphi/Pascal GUI application with Google Analytics


You can link our SoftMeter DLL with your Delphi/Pascal software and see the usage statistics in Google Analytics, for free. SoftMeter is an API client of the Google measurement protocol and connects any desktop application with the Google Analytics reporting platform.

If you are a shareware developer, you will be able to see the ratio of the free installations vs the paying users of your shareware and understand the conversion bottlenecks.

SoftMeter provides usage statistics like:

Installs vs uninstalls.
Users' countries and prefered languages.
Operating systems and screen resolutions.
Active installations.
App versions and editions (e.g. Free vs Paid)
Most and least used features of the program
Crashes and exceptions

The implementation is kept very easy. You can complete it in a few hours (together with the setup of the Google Analytics property), and start seeing real-time and historical data of your software's usage around the world.

In your Delphi project you will need a new unit to hold the global object of the SoftMeter class. You will use this object from various places of your software to send hits to your Google Analytics property.

A minimal example of the new unit: "softMeter_globalVar.pas"



unit softMeter_globalVar;

interface

uses dll_loaderAppTelemetry;

// this is the global variable that multiple units of the application will use
var dllSoftMeter: TDllAppTelemetry;

implementation

initialization

  userGaveConsent:= true; // make sure you load this variable from the user settings
  dllSoftMeter := TDllAppTelemetry.Create(DLLfilename);
  dllSoftMeter.start(AppName, AppVersion, AppLicense, AppEdition, GooglePropertyID, userGaveConsent );

finalization

  dllSoftMeter.stop;


If you have a base form that all other forms inherit from, add the tracking code in the base form.

It would be good to add an "Enable analytics" form property so that you can disable the tracking of non-important forms. Reducing the google analytics hits, allows you to focus on the important hit sequences.

A minimal example of the base form:



procedure TBaseForm.FormShow(Sender: TObject);
begin
  // send a pageView hit on Form Show
  dllSoftMeter.sendPageview( 'MainForm/' , 'MainForm' ); // you can pick the form's caption dynamically.
  // or send screenView
  dllSoftMeter.sendScreenView('MainForm');
end;


If you have important button clicks that you want to track, e.g. click on the "buy now" or the "Donate" button, you can send event hits.

A minimal example of sending event hits:



procedure TForm1.Button1Click(Sender: TObject);
begin
  dllSoftMeter.sendEvent('Conversion events', 'Donate clicked', 1);
end;


You can see the full Delphi GUI application example at our Github page.

After implementing SoftMeter with your Delphi software, you can log in to Google Analytics and see reports and graphs like the following:



Source:

https://www.starmessagesoftware.com/blog/track-delphi-pascal-gui-application-google-analytics