Skip to content

Commit d17eb43

Browse files
committed
Add more tracking parameters for user agent data, ecommerce product, bot recording mode, HTTP status, bandwidth, source label and media attributes.
1 parent d97acc5 commit d17eb43

3 files changed

Lines changed: 369 additions & 0 deletions

File tree

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ Projects that use Matomo Java Tracker:
7171

7272
### Version 3.5.x
7373

74+
Added more tracking parameters for user agent data, ecommerce product, bot recording mode, HTTP status, bandwidth,
75+
source label and media attributes.
76+
7477
The Spring Boot Starter now requires Spring Boot 4. The `@NonNull` annotation has been migrated from
7578
`org.springframework.lang.NonNull` to `org.jspecify.annotations.NonNull` across the Spring module. The
7679
`PropertyMapper` usage was updated to align with the Spring Boot 4 API (`alwaysApplyingWhenNonNull()` was removed).

core/src/main/java/org/matomo/java/tracking/MatomoRequest.java

Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,16 @@ public class MatomoRequest {
210210
@TrackingParameter(name = "ua")
211211
private String headerUserAgent;
212212

213+
/**
214+
* JSON-encoded <a
215+
* href="https://developer.chrome.com/docs/privacy-security/user-agent-client-hints">User Agent
216+
* Client Hints</a> collected by JavaScript. Used to enrich the detected user agent data.
217+
*
218+
* <p>Example: {@code {"brands":[{"brand":"Chromium","version":"110"}],"mobile":false}}
219+
*/
220+
@TrackingParameter(name = "uadata")
221+
private String clientHints;
222+
213223
/**
214224
* An override value for the Accept-Language HTTP header field. This value is used to detect the
215225
* visitor's country if GeoIP is not enabled.
@@ -407,6 +417,40 @@ public class MatomoRequest {
407417
@TrackingParameter(name = "_ects")
408418
private Instant ecommerceLastOrderTimestamp;
409419

420+
/**
421+
* The SKU of the product being viewed. Used for ecommerce product page tracking.
422+
*
423+
* <p>Requires {@code idgoal=0} and {@code _pks} to be set.
424+
*/
425+
@TrackingParameter(name = "_pks")
426+
private String ecommerceProductSku;
427+
428+
/**
429+
* The name of the product being viewed. Used for ecommerce product page tracking.
430+
*
431+
* <p>Requires {@code idgoal=0} and {@code _pks} to be set.
432+
*/
433+
@TrackingParameter(name = "_pkn")
434+
private String ecommerceProductName;
435+
436+
/**
437+
* The category of the product being viewed. Used for ecommerce product page tracking.
438+
*
439+
* <p>Can be a string or a JSON-encoded array of up to five category names.
440+
*
441+
* <p>Requires {@code idgoal=0} and {@code _pks} to be set.
442+
*/
443+
@TrackingParameter(name = "_pkc")
444+
private String ecommerceProductCategory;
445+
446+
/**
447+
* The price of the product being viewed. Used for ecommerce product page tracking.
448+
*
449+
* <p>Requires {@code idgoal=0} and {@code _pks} to be set.
450+
*/
451+
@TrackingParameter(name = "_pkp", min = 0)
452+
private Double ecommerceProductPrice;
453+
410454
/**
411455
* 32 character authorization key used to authenticate the API request. We recommend to create a
412456
* user specifically for accessing the Tracking API, and give the user only write permission on
@@ -486,6 +530,34 @@ public class MatomoRequest {
486530
@TrackingParameter(name = "bots")
487531
private Boolean trackBotRequests;
488532

533+
/**
534+
* When {@code bots=1} is set, this specifies the recording mode for bot requests.
535+
*
536+
* <p>Set to {@code 1} to record bot requests without triggering any goals, events or actions.
537+
*/
538+
@TrackingParameter(name = "recMode")
539+
private Integer botRecordingMode;
540+
541+
/**
542+
* The HTTP status code of the tracked request. Used with bot tracking.
543+
*
544+
* <p>When tracking a bot visit, this can be set to the HTTP status code of the bot's request.
545+
*/
546+
@TrackingParameter(name = "http_status")
547+
private Integer httpStatusCode;
548+
549+
/** The bandwidth used for the tracked request in bytes. Used with bot tracking. */
550+
@TrackingParameter(name = "bw_bytes", min = 0)
551+
private Long bandwidthBytes;
552+
553+
/**
554+
* Defines the source of the tracking request (e.g., {@code "backend"} or {@code "mobile-app"}).
555+
*
556+
* <p>Used to classify where the tracking hit originated.
557+
*/
558+
@TrackingParameter(name = "source")
559+
private String sourceLabel;
560+
489561
/**
490562
* Meant to hold a random value that is generated before each request. Using it helps avoid the
491563
* tracking request being cached by the browser or a proxy.
@@ -501,6 +573,99 @@ public class MatomoRequest {
501573
@TrackingParameter(name = "debug")
502574
private Boolean debug;
503575

576+
/**
577+
* A unique ID used to identify the media. Part of the <a
578+
* href="https://plugins.matomo.org/MediaAnalytics">Media Analytics</a> plugin.
579+
*/
580+
@TrackingParameter(name = "ma_id")
581+
private String mediaId;
582+
583+
/**
584+
* The title of the media resource. Part of the <a
585+
* href="https://plugins.matomo.org/MediaAnalytics">Media Analytics</a> plugin.
586+
*/
587+
@TrackingParameter(name = "ma_ti")
588+
private String mediaTitle;
589+
590+
/**
591+
* The URL of the media resource. Part of the <a
592+
* href="https://plugins.matomo.org/MediaAnalytics">Media Analytics</a> plugin.
593+
*/
594+
@TrackingParameter(name = "ma_re")
595+
private String mediaResource;
596+
597+
/**
598+
* The type of media, e.g. {@code "video"} or {@code "audio"}. Part of the <a
599+
* href="https://plugins.matomo.org/MediaAnalytics">Media Analytics</a> plugin.
600+
*/
601+
@TrackingParameter(name = "ma_mt")
602+
private String mediaType;
603+
604+
/**
605+
* The name of the media player used to play the media, e.g. {@code "html5"}. Part of the <a
606+
* href="https://plugins.matomo.org/MediaAnalytics">Media Analytics</a> plugin.
607+
*/
608+
@TrackingParameter(name = "ma_pn")
609+
private String mediaPlayerName;
610+
611+
/**
612+
* The number of seconds the visitor has spent playing/watching the media resource so far. Part of
613+
* the <a href="https://plugins.matomo.org/MediaAnalytics">Media Analytics</a> plugin.
614+
*/
615+
@TrackingParameter(name = "ma_st", min = 0)
616+
private Integer mediaTimeSpent;
617+
618+
/**
619+
* The total duration / length of the media resource in seconds. Part of the <a
620+
* href="https://plugins.matomo.org/MediaAnalytics">Media Analytics</a> plugin.
621+
*/
622+
@TrackingParameter(name = "ma_le", min = 0)
623+
private Integer mediaLength;
624+
625+
/**
626+
* The current progress of the media in percent (0–100). Part of the <a
627+
* href="https://plugins.matomo.org/MediaAnalytics">Media Analytics</a> plugin.
628+
*/
629+
@TrackingParameter(name = "ma_ps", min = 0, max = 100)
630+
private Integer mediaProgressPercent;
631+
632+
/**
633+
* How many seconds it took before the media started playing. Part of the <a
634+
* href="https://plugins.matomo.org/MediaAnalytics">Media Analytics</a> plugin.
635+
*/
636+
@TrackingParameter(name = "ma_ttp", min = 0)
637+
private Integer mediaTimeToPlay;
638+
639+
/**
640+
* The width of the media player in pixels. Part of the <a
641+
* href="https://plugins.matomo.org/MediaAnalytics">Media Analytics</a> plugin.
642+
*/
643+
@TrackingParameter(name = "ma_w", min = 0)
644+
private Integer mediaWidth;
645+
646+
/**
647+
* The height of the media player in pixels. Part of the <a
648+
* href="https://plugins.matomo.org/MediaAnalytics">Media Analytics</a> plugin.
649+
*/
650+
@TrackingParameter(name = "ma_h", min = 0)
651+
private Integer mediaHeight;
652+
653+
/**
654+
* Whether the media is currently displayed in fullscreen. Part of the <a
655+
* href="https://plugins.matomo.org/MediaAnalytics">Media Analytics</a> plugin.
656+
*/
657+
@TrackingParameter(name = "ma_fs")
658+
private Boolean mediaFullscreen;
659+
660+
/**
661+
* A JSON-encoded array of which positions in the media were viewed by the visitor. Part of the <a
662+
* href="https://plugins.matomo.org/MediaAnalytics">Media Analytics</a> plugin.
663+
*
664+
* <p>Example: {@code [[0,15],[30,44]]} means the visitor watched segments 0–15s and 30–44s.
665+
*/
666+
@TrackingParameter(name = "ma_se")
667+
private String mediaSegmentsViewed;
668+
504669
/**
505670
* Contains an error message describing the error that occurred during the last tracking request.
506671
*

0 commit comments

Comments
 (0)