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: |
||||||||
enableJS |
Boolean |
— |
Enables experiments with JavaScript code insertion through the editor. Default value: Ignored if |
||||||||
enableHTML |
Boolean |
— |
Enables experiments with HTML code insertion through the editor. Default value: Ignored if |
||||||||
enableRedir |
Boolean |
— |
Enables experiments with redirects. Default value: |
||||||||
enableWatch |
Boolean |
— |
Enables page change tracking. Default value: Learn moreWhen set to |
||||||||
enableAdv |
Boolean |
— |
Enables experiments with ad units. Default value: |
||||||||
enableSendYmUid |
Boolean |
— |
Enables sending Yandex Metrica cookies to Default value: |
||||||||
enableSetYmUid |
Boolean |
— |
Enables setting Yandex Metrica cookies. Default value: Ignored if To run experiments on ad units in the Yandex Advertising Network, set the |
||||||||
cookieDomain |
String |
— |
Defines the domain for setting cookies. Default value: If ExampleIf the site |
||||||||
storeReferer |
Boolean |
— |
Enables saving the Referer in the sessionStorage upon redirect so that it can be sent to Yandex Metrica. Default value: 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:
Default value: |
||||||||
removeAbRedirParam |
Boolean |
— |
Enables removal of the Default value: In experiments with redirects, the |
||||||||
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