file

Tip. 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(XXXXXX, 'file', url[, options]);

Parameter

Default value

Type

Description

url *

string

URL of the downloaded file

ym(XXXXXX, '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

options.params fields:
order_price

Double

Goal cost. You can set the cost in currency or Yandex units

currency

string

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

If a different currency is passed, null values will be sent instead of currencies and amounts

* Required parameter.

The url and options.referer parameters let you use URL paths without a schema (protocol) or host.

In this case, if a path starts with a / the URL is assumed to be set from the root of the host.
ym(XXXXXX, 'file', '/downloads/price.zip');

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

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

Goal cost

If file download is one of the goals set on your website, you can transmit the price in the method parameters. Read more about goal cost

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