TagSpy

file_download

Enhanced measurementweb

Automatically triggered when a user clicks a link leading to a file (with a common file extension) of the following types: - document - text - executable - presentation - compressed file - video - audio File extensions that match the following regex will trigger the event: pdf|xlsx?|docx?|txt|rtf|csv|exe|key|pp(s|t|tx)|7z|pkg|rar|gz|zip|avi|mov|mp4|mpe?g|wmv|midi?|mp3|wav|wma

Platforms
web
When it fires
Collected automatically; no code needed.
Official docs

Parameters (7)

ParameterTypeRequiredDescriptionExample
file_extension--The extension of a file download (for example, 'pdf' or 'txt').-
file_name--The page path of a file download (for example, '/menus/dinner-menu.pdf').-
link_classes--The HTML class attribute for an outbound link or file download. For example, if a user clicks a link '<a class='center' href='www.youtube.com';', this dimension returns 'center'.-
link_domain--The destination domain of an outbound link or file download. For example, if a user clicks a link '', this dimension returns 'youtube.com'.-
link_id--The HTML id attribute for an outbound link or file download. For example, if a user clicks a link '<a id='socialLinks' href='www.youtube.com'>', this dimension returns 'socialLinks'.-
link_text--The link text of a file download.-
link_url--The full URL for an outbound link or file download. For example, if a user clicks a link '<a href='https://www.youtube.com/results?search_query=analytics'>', this dimension returns 'https://www.youtube.com/results?search_query=analytics'.-

Example

gtag.js
gtag('event', 'file_download', {
  file_extension: '...',
  file_name: '...',
  link_classes: '...',
  link_domain: '...',
});
GTM dataLayer
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
  event: 'file_download',
  file_extension: '...',
  file_name: '...',
  link_classes: '...',
  link_domain: '...',
});

Also see