Skip to content
This repository has been archived by the owner on Jun 24, 2020. It is now read-only.

Commit

Permalink
Added analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
Falaleev Maxim committed Jan 31, 2018
1 parent 56c9bd7 commit 5a112dc
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 0 deletions.
2 changes: 2 additions & 0 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ enableMissingTranslationPlaceholders = false
editURL = "https://github.com/MindyPHP/doc.mindy-cms.com/edit/master/content/"
ordersectionsby = "weight"
enableGitInfo = true
analytics_yandex = "47511355"
analytics_google = "UA-6744947-18"

[outputs]
home = [ "HTML", "RSS", "JSON"]
Expand Down
2 changes: 2 additions & 0 deletions themes/hugo-simple-doc/layouts/_default/baseof.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
</div>
</div>
</div>

{{ partial "analytics.html" . }}
</div>
</body>
</html>
2 changes: 2 additions & 0 deletions themes/hugo-simple-doc/layouts/partials/analytics.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{{ partial "analytics_yandex.html" . }}
{{ partial "analytics_google.html" . }}
9 changes: 9 additions & 0 deletions themes/hugo-simple-doc/layouts/partials/analytics_google.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id={{ .Site.Params.analytics_google }}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('config', '{{ .Site.Params.analytics_google }}');
</script>
31 changes: 31 additions & 0 deletions themes/hugo-simple-doc/layouts/partials/analytics_yandex.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<script type="text/javascript" >
(function (d, w, c) {
(w[c] = w[c] || []).push(function() {
try {
w[{{ printf "yaCounter%s" .Site.Params.analytics_yandex }}] = new Ya.Metrika2({
id:{{- .Site.Params.analytics_yandex -}},
clickmap:true,
trackLinks:true,
accurateTrackBounce:true,
webvisor:true
});
} catch(e) { }
});

var n = d.getElementsByTagName("script")[0],
s = d.createElement("script"),
f = function () { n.parentNode.insertBefore(s, n); };
s.type = "text/javascript";
s.async = true;
s.src = "https://mc.yandex.ru/metrika/tag.js";

if (w.opera == "[object Opera]") {
d.addEventListener("DOMContentLoaded", f, false);
} else { f(); }
})(document, window, "yandex_metrika_callbacks2");
</script>
<noscript>
<div>
<img src="https://mc.yandex.ru/watch/{{ .Site.Params.analytics_yandex }}" style="position:absolute; left:-9999px;" alt="" />
</div>
</noscript>

0 comments on commit 5a112dc

Please sign in to comment.