trackOutboundLink method

Future<void> trackOutboundLink(
  1. String url, {
  2. String? text,
  3. String? pathname,
})

Tracks an outbound link click.

url - The destination URL text - Optional link text pathname - Optional page path where the link was clicked

Implementation

Future<void> trackOutboundLink(
  String url, {
  String? text,
  String? pathname,
}) async {
  _ensureInitialized();

  final screenInfo = _getScreenInfo();
  final properties = {'url': url, 'text': ?text, 'target': '_blank'};

  final event = TrackEvent.outbound(
    siteId: _config.siteId,
    outboundProperties: properties,
    pathname: pathname,
    hostname: _hostname,
    screenWidth: screenInfo.width.round(),
    screenHeight: screenInfo.height.round(),
    userAgent: _userAgent,
    userId: _userId,
    language: PlatformInfo.localeName,
  );

  await _sendTrackingEvent(event);
}