trackPageViewWithName method

void trackPageViewWithName({
  1. required String actionName,
  2. String? pvId,
  3. String? path,
  4. Campaign? campaign,
  5. Map<String, String>? dimensions,
  6. PerformanceInfo? performanceInfo,
  7. bool? newVisit,
})

Registers a page view.

actionName represents the page name, here used to identify the screen with a proper name. Corresponds with action_name.

pvId is a 6 character unique ID that can later be used to associate other actions (like trackEvent) with this page view. If null, a random id will be generated (recommended). Also see 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 trackPageViewWithName({
  required String actionName,
  String? pvId,
  String? path,
  Campaign? campaign,
  Map<String, String>? dimensions,
  PerformanceInfo? performanceInfo,
  bool? newVisit,
}) {
  _initializationCheck();

  if (pvId != null && pvId.length != 6) {
    throw ArgumentError.value(
      pvId,
      'pvId',
      'The pvId must be 6 characters long.',
    );
  }

  validateDimension(dimensions);
  final lastPageView = MatomoAction(
    action: actionName,
    path: path,
    campaign: campaign,
    dimensions: dimensions,
    pvId: pvId ?? randomAlphaNumeric(6),
    performanceInfo: performanceInfo,
    newVisit: _inferNewVisit(newVisit),
  );
  _lastPageView = lastPageView;
  return _track(lastPageView);
}