file

Warning

Working with the JavaScript API requires knowledge of HTML and JavaScript. If you don’t know these languages, contact your website developer or webmaster.

Sends information about file downloads.

The data collected is used when generating File downloads reports.

ym(XXXXXXXX, 'file', url[, options]);

Parameter

Default value

Type

Description

url*

String

The URL of the downloaded file
javascript ym(XXXXXXXX, 'file', 'http://example.com/files/price.zip');

options

Object

options fields

options.callback

Function

The callback function called after sending data about a file download

options.ctx

Object

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

Fields for the options.params object:

order_price

Double

Revenue by goal. You can set the cost in a currency or conventional units.

currency

String

Use this field if you want to pass the goal cost in currency. Yandex Metrica recognizes a three-letter ISO 4217 currency code.

If a different currency is passed, null values are sent instead of currencies and amounts.

* Required parameter.

With the url and options.referer parameters, you can use URL paths without a schema (protocol) and host.

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

ym(XXXXXXXX, 'file', '/downloads/price.zip');

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

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

Revenue by goal

If file download is one of the goals set on your site, you can transmit the revenue in the method parameters.

Example:

var goalParams =
{
   order_price: 1000.35,
   currency: "RUB"
};
ym(XXXXXXXX, 'file', '../downloads/price.zip', goalParams)

Chat with us

Write an email

Please note: Our support team will never initiate a call to you. Do not follow any instructions of people who call you and introduce themselves as the Yandex Metrica support team.


* Required parameter.