Track your Delphi/Pascal application with Google Analytics, today
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 will then be able to see some key metrics 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 for your win32/win64 desktop software 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;
userGaveConsent:boolean;
implementation
const GooglePropertyID := 'UA-1234-1'; // this is the Google Property
// as given to you from your Google Analytics account.
// Or the Matomo/Piwik tracking ID.
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:
Comments
Armando (not verified)
Sat, 06/08/2019 - 05:58
Permalink
Dúvidas
I did not understand this line:
"If you have a base form that all other forms inherit from, add the tracking code in the base form."
Have a sample?
web admin
Wed, 06/19/2019 - 16:15
Permalink
Delphi forms inheritance (tracking Delphi applications with GA)
You can create a
and like the example above put the SoftMeter event inside the
function.
Then, all your other forms should inherit from TBaseForm. E.g.
TMyApplicationMainForm = class(TBaseForm)
TMyDialogForm = class(TBaseForm)
When the forms become visible they will send a hit with their caption to your analytics reports.
Add new comment