enableLinkTracking

The enableLinkTracking() method enables the automatic tracking of downloads and outlinks. Downloads are clicks on links to downloadable files. Outlinks are clicks on links to external websites (different domains).

Syntax

enableLinkTracking([trackMiddleAndRightClicks])
enableLinkTracking(trackAlsoMiddleAndRightClicks?): void
enableLinkTracking(trackAlsoMiddleAndRightClicks?): void
enableLinkTracking(trackAlsoMiddleAndRightClicks?): void
enableLinkTracking(trackAlsoMiddleAndRightClicks?): void
enableLinkTracking(trackAlsoMiddleAndRightClicks?): void
enableLinkTracking(trackAlsoMiddleAndRightClicks?): void

Parameters

trackMiddleAndRightClicks (boolean, optional)

Whether to treat middle and right clicks as opening a link. The default value is true.

Examples

To automatically track downloads and outlinks:

_paq.push(["trackPageView"]);  
_paq.push(["enableLinkTracking"]);
enableLinkTracking(trackAlsoMiddleAndRightClicks?): void
enableLinkTracking(trackAlsoMiddleAndRightClicks?): void
enableLinkTracking(trackAlsoMiddleAndRightClicks?): void
enableLinkTracking(trackAlsoMiddleAndRightClicks?): void
enableLinkTracking(trackAlsoMiddleAndRightClicks?): void
enableLinkTracking(trackAlsoMiddleAndRightClicks?): void

Notes

  • This method is part of the container code (or tracking code) that you've installed on your site to use Piwik PRO. Most likely your setup already uses it.
  • This method needs to be called after the first trackPageView() or trackEvent().
  • Outlinks are tracked when a visitor clicks on a link to an external site (different domain). You can use the setDomains method to define domains and subdomains that belong to you. Then clicks on URLs to these domains won't be tracked as outlinks.

Related methods