Skip to content

A very simple library that allows to send Google Analytics 4 events

License

Notifications You must be signed in to change notification settings

ichlubna/SimpleQtGA4

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SimpleQtGA4

A very simple library that allows to send Google Analytics 4 events.

Instalation

Add ga4.hpp to the HEADERS in your project ad add Qt network module.

Usage

//C++
GA4 ga4("YOUR_ID");
ga4.sendEvent("ObiWan", {"talk", "HelloThere"});

//QML
GA4{
  id: ga4
      measurementID: "YOUR_ID"}
onActiveChanged: { ga4.sendEvent("Gandalf", ["talk", "YouShallNotPass"]) }

Use the functions like:

sendEvent(eventName, eventParameters, turnOnDebugMode)

QString eventName - name of the event

QList eventParameters - pairs of parameters ["firstParamName", "firstParamValue",...]

bool turnOnDebugMode - if set to True, the events are shown in a few seconds in the Analytics realtime view and are deleted after 30 minutes

overrideDebugMode(debug)

bool debug - all events will be in debug mode (ignoring the turnOnDebugMode parameter) if true, call with false to turn it off

Additional info

You can obtain your ID when creating a Google Analytics service and creating a web data stream. Then you can get a Measurement ID there starting with G-..

If you send the events with custom parameters, you have to define them in Google Analytics settings, otherwise they will not be stored! You can do so by selecting Configure section and Custom definitions. Follow this tutorial.

This library does not do any local storing of the events. All events are sent right when the function is called and in case of no Internet connection they are lost.

If you encounter a problem with encryption, not being able to send the request, you need to install SSL libraries for your given platform. Another hack is to change https to http in the analyticsURL private member.

Sources

Limits for the event properties (length of the event etc.)

APP + WEB: Google Analytics Measurement Protocol version 2 Date

Measurement protocol V2 Google analytics Apps+Web

About

A very simple library that allows to send Google Analytics 4 events

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published