Created
July 21, 2021 13:21
-
-
Save peterkarn/d4350e9cb4173b77c65bb6030738220e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- lazy load metrika and jivosite --> | |
<script> | |
function appendScriptMetrika() { | |
const metrikaScript = | |
`(function (m, e, t, r, i, k, a) { m[i] = m[i] || function () { (m[i].a = m[i].a || []).push(arguments) }; m[i].l = 1 * new Date(); k = e.createElement(t), a = e.getElementsByTagName(t)[0], k.async = 1, k.src = r, a.parentNode.insertBefore(k, a)}) (window, document, "script", "https://mc.yandex.ru/metrika/tag.js", "ym"); ym(61222240, "init", { clickmap: true, trackLinks: true, accurateTrackBounce: true});` | |
const scriptTag = document.createElement('script'); | |
scriptTag.innerHTML = metrikaScript; | |
document.head.appendChild(scriptTag) | |
} | |
function createScriptSrc() { | |
const scriptTag = document.createElement('script'); | |
scriptTag.setAttribute('src', 'https://code-ya.jivosite.com/widget/cYH9lgEYsT'); | |
document.body.append(scriptTag) | |
} | |
document.addEventListener('scroll', () => { | |
createScriptSrc(); | |
appendScriptMetrika(); | |
}, { | |
once: true, | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment