Skip to content

Commit

Permalink
Add Yandex.Metrika counter (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
gomzyakov authored Nov 28, 2024
1 parent dddfb35 commit 83d0a99
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 24 deletions.
3 changes: 3 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ favicon: images/favicon.png
# Google Analytics id, e.g. "UA-NNNNNNNN-N"
google_analytics: "G-3712TB0863"

# Yandex.Metrika counter
yandex_metrika: "99021176"

# Site navigation - each item must have a title and a url.
navigation:
- text: Blogs Home
Expand Down
16 changes: 16 additions & 0 deletions _includes/yandex_metrika.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!-- Yandex.Metrika counter -->
<script type="text/javascript" >
(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();
for (var j = 0; j < document.scripts.length; j++) {if (document.scripts[j].src === r) { return; }}
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({{ site.yandex_metrika }}, "init", {
clickmap:true,
trackLinks:true,
accurateTrackBounce:true
});
</script>
<noscript><div><img src="https://mc.yandex.ru/watch/{{ site.yandex_metrika }}" style="position:absolute; left:-9999px;" alt="" /></div></noscript>
<!-- /Yandex.Metrika counter -->
55 changes: 31 additions & 24 deletions _layouts/default.html
Original file line number Diff line number Diff line change
@@ -1,36 +1,43 @@
<!DOCTYPE html>
<html lang="{{ site.lang | default: 'en-US' }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{% if page.title %}{{ page.title | escape }}{% else %}{{ site.title | escape }}{% endif %}</title>
<meta name="description" content="{{ page.description | default: site.description | strip_html | normalize_whitespace | truncate: 160 | escape }}">
<link rel="canonical" href="{{ page.url | replace:'index.html', '' | absolute_url }}">
<link rel="alternate" type="application/rss+xml" title="{{ site.title | escape }} Feed"
href="{{ '/feed.xml' | absolute_url }}">
{% if site.favicon and site.favicon != "" %}
<link rel="shortcut icon" href="{{ site.favicon | relative_url }}" type="image/png" />
{% endif %}
<!-- Styles -->
<link href="https://fonts.googleapis.com/css?family=Lato:400,400i,700,700i%7CNoto+Serif:400,400i,700,700i&display=swap" rel="stylesheet">
<link href="{{ '/assets/css/style.css' | relative_url }}" rel="stylesheet">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{% if page.title %}{{ page.title | escape }}{% else %}{{ site.title | escape }}{% endif %}</title>
<meta name="description"
content="{{ page.description | default: site.description | strip_html | normalize_whitespace | truncate: 160 | escape }}">
<link rel="canonical" href="{{ page.url | replace:'index.html', '' | absolute_url }}">
<link rel="alternate" type="application/rss+xml" title="{{ site.title | escape }} Feed"
href="{{ '/feed.xml' | absolute_url }}">
{% if site.favicon and site.favicon != "" %}
<link rel="shortcut icon" href="{{ site.favicon | relative_url }}" type="image/png"/>
{% endif %}
<!-- Styles -->
<link href="https://fonts.googleapis.com/css?family=Lato:400,400i,700,700i%7CNoto+Serif:400,400i,700,700i&display=swap"
rel="stylesheet">
<link href="{{ '/assets/css/style.css' | relative_url }}" rel="stylesheet">
</head>
<body>

<div id="page" class="site">
<div id="page" class="site">
<div class="inner">
{% include header.html %}
{{content}}
{% include footer.html %}
{% include header.html %}
{{content}}
{% include footer.html %}
</div><!-- .inner -->
</div><!-- .site -->
</div><!-- .site -->

<!-- Scripts -->
{% if site.google_analytics %}
{% include google_analytics.html %}
{% endif %}
<script src="{{ '/assets/js/plugins.js' | relative_url }}"></script>
<script src="{{ '/assets/js/custom.js' | relative_url }}"></script>
<!-- Scripts -->
<script src="{{ '/assets/js/plugins.js' | relative_url }}"></script>
<script src="{{ '/assets/js/custom.js' | relative_url }}"></script>

{% if site.google_analytics %}
{% include google_analytics.html %}
{% endif %}

{% if site.yandex_metrika %}
{% include yandex_metrika.html %}
{% endif %}

</body>
</html>

0 comments on commit 83d0a99

Please sign in to comment.