Documentation: Calls Reference
Track download links as page views under the /download/ path. Once this call is included you do not have to modify any of the individual links.
if both _trackOutbound and _trackDownload are present and the link leads to an externally downloadable document, the same event will be tracked under two distinct metrics.
onBounce: true, // optional boolean
method: 'page', // optional 'page'|'event'
category: 'download', // optional string
action: 'click', // optional 'click'|'mouseup'
value: 0, // optional real
include: /\.(docx*|xlsx*|pptx*|exe|rar|zip|pdf|xpi|mp3|mp4|flv|wmv)$/i, // optional regex
exclude: /^$/, // optional regex
format: '/%category%/%action%/%hostname%%pathname%', // optional string
selector: 'a', // optional jQuery selector
- Q) Track download for specific directories or folders
- A) The "include" option is a regular expression, so if you want to "track the download of PDF documents being served from a specific domain and folder":
- Q) I have a large library of PDF documents, how can I track it more effectively?
- A) An interesting option is to use use something like
- Q) My PDF files are going through a redirect page, something like /ref.aspx?id=12345
- A) The following would track this download as page view under /PDFdownload/id=12345:
- Q) I want some files to be tracked differently
- A) You can use multiple _trackDownload calls, each one with its specific options.
- Q) Can I stak up multiple _trackDownload calls to track different types of documents?
- A) Yes, absolutely, you can do something like this:
- onBounce true|false
- By default, tracking downloads will affect the bounce rate. Set this option to false if you don't want to affect your bounce rate - downloads won't be tracked if happening on the first page of the visit.
- method 'page'|'event'
- By default, download links are tracked as page views. If set to 'event', the behaviour will be to tracked using an event.
- category 'download'|string
- Download links are tracked with a Category, Action, optional Label and optional Value. This is the label that will show under the Content/Event Tracking/Categories report. If not using events, Category, Action and Label will be the faked page hierarchy represented as /Category/Action/Label. Label is the complete URL of the download link. This parameter default value is 'download'.
- action 'click'|'mouseup'
- The event label showing up under GA report /Content/Event Tracking/Actions.
If action is set to 'mouseup' then the left, middle and right mouse buttons will be tracked as well as the regular 'click' event. Be forewarned using 'mouseup' simply means those buttons were pressed, not that the document was actually downloaded (i.e. someone can press the right-button to "open in new window", "save as..." or nothing at all). This parameter default value is 'click'.
- value 0|real
- If using the event method, you can assign a value for this event. This parameter can not be used when method is set to 'page'. This parameter default value is 0.
- include /\.(docx*|xlsx*|pptx*|exe|rar|zip|pdf|xpi|mp3)$/i|regex
- The include filter is used to specify which download links are to be tracked. This parameter default value is /\.(docx*|xlsx*|pptx*|exe|rar|zip|pdf|xpi|mp3)$/i, meaning any link with a commonly used file extension will be tracked.
- exclude /^$/|regex
- The exclude filter can be used to exclude download link tracking for specific URLs. By default, nothing is excluded (/^$/ will always be false). For example, if you set this option to /mydir/ all download links will be tracked (based on the 'include' parameter filter) except those linking to documents somewhere under the 'mydir' directory.
- format '/%category%/%event/%hostname%%pathname%'|string
- Specify the desired taxonomy for tracking. A number of special strings can be replaced by their run-time values in order to categorize the data in the way you want. The list of supported variables are:
Note: If tracking with an event, the 1st path level is the category, the 2nd one is the action, and anything else is the label.
- %category% - the value of the "category" option
- %action% - the value of the "action" option
- %target% - the A HREF TARGET value
- %value% - the value option
- %pagename% - the current page title
- %title% - the link text
- %filetype% - the part of %pathname% after the last .
Make sure to begin the format with a '/' and have at least three of them. Tracking with page views doesn't have this constraint.
- selector 'a'|jQuery selector
- Advanced use only: allow you to specify an alternative jQuery selector.
- button ['click','clickl','clickm','clickr'] | string array
- A four items array that represent a generic button click, left-click, middle-click or rick-click labels