Metrica

file

Tip. Working with the JavaScript API requires knowledge of HTML and JavaScript. If you don't have these skills, contact your website developer or webmaster.

Sending information about file downloads.

The collected data is used when generating the File downloads report.

file(url[, options])

Parameter

Default value

Type

Description

url *
[no-highlight[

* Required parameter.

]no-highlight]

String

URL of the downloaded file.

yaCounterXXXXXX.file('http://my_site.ru/files/price.zip');
options

Object

Field for the options object
options.callback

Function

The callback function called after sending data about a file download

options.ctx

Object

The context accessed by the this keyword in the callback function

options.params

Object

Session parameters

options.referer

String

URL that the user downloaded the file from

options.title document.title

String

Title of the current page

* Required parameter.

The url and options.referer parameters allow using URL paths without the schema (protocol) and host.

In this case, if a path starts with the / symbol, the URL is assumed to be set from the root of the host.

yaCounterXXXXXX.files('/downloads/price.zip');

Otherwise, the path is assumed to be relative to the current page.

yaCounterXXXXXX.files('../downloads/price.zip', {referer: 'index.html?page=goods'});