The trackLink() method tracks downloads and outlinks. Downloads are clicks on links to downloadable files. Outlinks are clicks on links to external websites (different domain).

Syntax

trackLink(linkAddress, linkType\[, dimensions[, callback]])
trackLink(url, linkType, dimensions?, callback?): void
trackLink(url, linkType, dimensions?, callback?): void
trackLink(url, linkType, dimensions?, callback?): void
trackLink(url, linkType, dimensions?, callback?): void
trackLink(url, linkType, dimensions?, callback?): void
trackLink(url, linkType, dimensions?, callback?): void

Parameters

linkAddress (string, required)

The URL address of the link.

linkType (string, required)

The type of the link. Values: "link" for outlink, "download" for download.

dimensions (object, optional)

A list of custom dimensions you want to pass with this event. Format for keys: dimensionX where X is the dimension ID. Format for values: percent-encoded (Use the encodeURIComponent() method to encode strings.)

callback (function, optional)

The method to call after the link is tracked.

Example

To track an outlink:

_paq.push(["trackLink", "http://www.example.com/example", "link"]);
trackLink("http://www.example.com/example", "link", dimensions?, callback?): void
trackLink("http://www.example.com/example", "link", dimensions?, callback?): void
trackLink("http://www.example.com/example", "link", dimensions?, callback?): void
trackLink("http://www.example.com/example", "link", dimensions?, callback?): void
trackLink("http://www.example.com/example", "link", dimensions?, callback?): void
trackLink("http://www.example.com/example", "link", dimensions?, callback?): void

To track an outlink after someone clicks a signup button tagged with the onclick attribute:

<button onclick="_paq.push(['trackLink', 'http://www.example.com/example', 'link'])">
    Sign up
</button>
trackLink("http://www.example.com/example", "link", dimensions?, callback?): void
trackLink("http://www.example.com/example", "link", dimensions?, callback?): void
trackLink("http://www.example.com/example", "link", dimensions?, callback?): void
trackLink("http://www.example.com/example", "link", dimensions?, callback?): void
trackLink("http://www.example.com/example", "link", dimensions?, callback?): void
trackLink("http://www.example.com/example", "link", dimensions?, callback?): void

Related methods