setConfig

Offers additional experiment settings and the ability to create experiments in the JS visual editor mode.

ymab('metrika.XXXX', 'setConfig', {
    enableVisual: true,
    enableJS: false,
    enableHTML: true,
    enableRedir: true,
    enableWatch: false,
    enableAdv: true,
    enableSendYmUid: true,
    enableSetYmUid: false,
    cookieDomain: undefined,
    storeReferer: false,
    storeRedirParam: "localstorage",
    removeAbRedirParam: false,
    nonce: undefined
});

where XXXX is the ID of the Yandex Metrica tag installed on your site.

Argument

Type

Required

Description

setConfig

String

Yes

Initializes the experiment.

Fields

enableVisual

Boolean

Enables experiments with the editor.

Default value: true.

enableJS

Boolean

Enables experiments with JavaScript code insertion through the editor.

Default value: false.

Ignored if enableVisual is false.

enableHTML

Boolean

Enables experiments with HTML code insertion through the editor.

Default value: true.

Ignored if enableVisual is false.

enableRedir

Boolean

Enables experiments with redirects.

Default value: true.

enableWatch

Boolean

Enables page change tracking.

Default value: false.

Learn more

When set to true, changes to the page's elements are constantly tracked from the moment the page is first loaded. When a change is detected, Varioqub scans the page again and applies the experiment to the new elements.

enableAdv

Boolean

Enables experiments with ad units.

Default value: true.

enableSendYmUid

Boolean

Enables sending Yandex Metrica cookies to uaas.yandex.ru.

Default value: true.

enableSetYmUid

Boolean

Enables setting Yandex Metrica cookies.

Default value: false.

Ignored if enableSendYmUid is false.

To run experiments on ad units in the Yandex Advertising Network, set the enableSetYmUid parameter to true.

cookieDomain

String

Defines the domain for setting cookies.

Default value: undefined.

If cookieDomain is undefined, cookies will be set on the domain of the current page.

Example

If the site example.com has subdomains — for example, ny.example.com and help.example.com — cookies will be set for each individual subdomain.
If a user enters a different subdomain in the address bar, they will be directed to different experiments. To prevent this, specify the domain example.com in the cookieDomain. Then all subdomains will have the same cookies, and users will be directed to the same experiments.

storeReferer

Boolean

Enables saving the Referer in the sessionStorage upon redirect so that it can be sent to Yandex Metrica.

Default value: false.

Use it when you need to save tags after a redirect.

storeRedirParam

String

Defines the temporary storage for a flag indicating a successful redirect. This flag is used to log the session in Yandex Metrica upon redirect.

Flags can be stored for up to five minutes. After a successful redirect, flags are automatically deleted.

Possible values:

Value

Where to store the flag

localstorage

Browser local storage.

cookie

Browser cookie file.

get

GET parameter in the URL of the landing page.

Use it when you need to send redirect information directly in the address bar.

Default value: localstorage.

removeAbRedirParam

Boolean

Enables removal of the ab_redir parameter from the page URL upon successful redirect.

Default value: false.

In experiments with redirects, the ab_redir parameter is added automatically when a redirect occurs in the control variant.

nonce

String

Added to CSS and JS if the site has a Content Security Policy. Learn more

Example of enabling JS

ymab('metrika.XXXX', 'setConfig', { enableJS: true});

Example of passing a nonce

ymab('metrika.XXXX', 'setConfig', { enableJS: true, nonce: 'nonce-<sequence of characters>' });

Call setConfig before or after the init method.

Example:

<script type="text/javascript">
    (function(e, x, pe, r, i, me, nt){
    e[i]=e[i]||function(){(e[i].a=e[i].a||[]).push(arguments)},
    me=x.createElement(pe),me.async=1,me.src=r,nt=x.getElementsByTagName(pe)[0],nt.parentNode.insertBefore(me,nt)})
    (window, document, 'script', 'https://abt.s3.yandex.net/expjs/latest/exp.js', 'ymab');
    ymab('metrika.XXXX', 'setConfig', { enableJS: true });
    ymab('metrika.XXXX', 'init'/*, {clientFeatures}, {callback}*/);
</script>

where XXXX is the ID of the Yandex Metrica tag installed on your site.

Questions and issues

Can I use a custom JS script in an A/B test?

How do I disable a specific experiment type for an entire site or page?

An element loads after the page. How do I include it in the experiment?

Yandex Advertising Network