Track your Delphi/Pascal GUI application with Google Analytics
If you are a shareware developer using Delphi or Lazarus, you can link the application analytics, SoftMeter DLL with your software and see the usage statistics in Google Analytics, for free.
SoftMeter is an API client for the Google measurement protocol. It connects any desktop application with the Google Analytics reporting platform.
You wil thenl be able to see some key metics for your distributed software product, like the ratio of the free installations vs the paying users of your shareware and be able to 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, taking the current classname and caption dllSoftMeter.sendPageview( PAnsiChar(Classname + '/ ' + Caption ), Caption ); // or send a screenView dllSoftMeter.sendScreenView(PAnsiChar(Classname + '/ ' + Caption )); 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: