trackGoal method

void trackGoal({
  1. required int id,
  2. double? revenue,
  3. String? pvId,
  4. String? path,
  5. Campaign? campaign,
  6. Map<String, String>? dimensions,
  7. bool? newVisit,
})

Tracks a conversion for a goal.

The id corresponds with idgoal and revenue with revenue.

To associate this action with a page view, enable attachLastScreenInfo and leave pvId to null here or set pvId to the pvId of that page view manually, e.g. TraceableClientMixin.pvId. Setting pvId manually will take precedance over attachLastScreenInfo.

path is a string that identifies the path of the screen where this action happend. If not null, it will be appended to contentBase to create a URL. This combination corresponds with url. Also see attachLastScreenInfo. Setting path manually will take precedance over attachLastScreenInfo.

campaign can be a campaign that lead to this action. Setting this multiple times during an apps lifetime can have some side effects, see the Campaign class for more information.

For remarks on dimensions see trackDimensions.

The newVisit parameter can be used to make this action the begin of a new visit. If it's left to null and this is the first track... call after MatomoTracker.initialize, the newVisit from there will be used.

Implementation

void trackGoal({
  required int id,
  double? revenue,
  String? pvId,
  String? path,
  Campaign? campaign,
  Map<String, String>? dimensions,
  bool? newVisit,
}) {
  _initializationCheck();

  validateDimension(dimensions);
  return _track(
    MatomoAction(
      goalId: id,
      revenue: revenue,
      pvId: _inferPvId(pvId),
      path: _inferPath(path),
      campaign: campaign,
      dimensions: dimensions,
      newVisit: _inferNewVisit(newVisit),
    ),
  );
}