matomo-org / matomo-java-tracker

Official Java implementation of the Matomo Tracking HTTP API.
https://matomo-org.github.io/matomo-java-tracker/
BSD 3-Clause "New" or "Revised" License
69 stars 52 forks source link

Automatic Setting of `goalId` to 0 in Presence of Ecommerce Parameters #162

Closed dheid closed 10 months ago

dheid commented 10 months ago

Currently, in the MatomoRequest Java class, users need to manually set the goalId parameter. However, if any ecommerce parameter is set without updating the goalId accordingly, it results in an exception on validation. To prevent such mistakes and enhance user experience, this enhancement request proposes automatic setting of the goalId to 0 when any ecommerce parameter is detected.

Expected Behavior

When any ecommerce parameter (ecommerceRevenue, ecommerceItems, ecommerceSubtotal, ecommerceTax, ecommerceShippingCost, ecommerceDiscount, ecommerceLastOrderTimestamp) is set, the MatomoRequest class should automatically set the goalId to 0.

Use Case

This enhancement is essential for scenarios where ecommerce data is being tracked. Automatic adjustment of the goalId ensures consistent and accurate representation of data in analytics.

Implementation Suggestion

Add a conditional check in the MatomoRequest class to automatically detect the presence of any ecommerce-related parameters. If such parameters are present, set the goalId to 0.

Additional Information

Acceptance Criteria