Date: Thu, 1 Jul 2021 22:44:24 GMT From: "Danilo G. Baio" <dbaio@FreeBSD.org> To: doc-committers@FreeBSD.org, dev-commits-doc-all@FreeBSD.org Subject: git: 09b36d7dd4 - main - Re-enable Google Analytics Message-ID: <202107012244.161MiOgR043248@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by dbaio: URL: https://cgit.FreeBSD.org/doc/commit/?id=09b36d7dd44df840ab4a1817b7d919fab8d8d8d9 commit 09b36d7dd44df840ab4a1817b7d919fab8d8d8d9 Author: Danilo G. Baio <dbaio@FreeBSD.org> AuthorDate: 2021-07-01 12:20:12 +0000 Commit: Danilo G. Baio <dbaio@FreeBSD.org> CommitDate: 2021-07-01 22:39:49 +0000 Re-enable Google Analytics We lost that after the migration to Hugo/Asciidoctor. Reviewed by: carlavilla Approved by: doceng (with hat) Differential Revision: https://reviews.freebsd.org/D30978 --- .../themes/beastie/layouts/articles/baseof.html | 2 + .../themes/beastie/layouts/books/baseof.html | 2 + .../themes/beastie/layouts/partials/site-head.html | 1 + documentation/themes/beastie/static/js/google.js | 52 ++++++++++++++++++++++ .../themes/beastie/layouts/partials/site-head.html | 2 + 5 files changed, 59 insertions(+) diff --git a/documentation/themes/beastie/layouts/articles/baseof.html b/documentation/themes/beastie/layouts/articles/baseof.html index 552ece4ca6..80bebc87f0 100644 --- a/documentation/themes/beastie/layouts/articles/baseof.html +++ b/documentation/themes/beastie/layouts/articles/baseof.html @@ -43,6 +43,8 @@ } </script> <!-- END SEO --> + + <script src="{{ absLangURL ($.Site.BaseURL) }}js/google.js"></script> </head> <body> <main> diff --git a/documentation/themes/beastie/layouts/books/baseof.html b/documentation/themes/beastie/layouts/books/baseof.html index 1f70b7c22e..50e97a6ea3 100644 --- a/documentation/themes/beastie/layouts/books/baseof.html +++ b/documentation/themes/beastie/layouts/books/baseof.html @@ -43,6 +43,8 @@ } </script> <!-- END SEO --> + + <script src="{{ absLangURL ($.Site.BaseURL) }}js/google.js"></script> </head> <body> <main> diff --git a/documentation/themes/beastie/layouts/partials/site-head.html b/documentation/themes/beastie/layouts/partials/site-head.html index f8caeca139..41d83c1544 100644 --- a/documentation/themes/beastie/layouts/partials/site-head.html +++ b/documentation/themes/beastie/layouts/partials/site-head.html @@ -41,4 +41,5 @@ </script> <!-- END SEO --> + <script src="{{ absLangURL ($.Site.BaseURL) }}js/google.js"></script> </head> diff --git a/documentation/themes/beastie/static/js/google.js b/documentation/themes/beastie/static/js/google.js new file mode 100644 index 0000000000..34bfefcc94 --- /dev/null +++ b/documentation/themes/beastie/static/js/google.js @@ -0,0 +1,52 @@ +/* $FreeBSD$ */ + +/* + * Please do not commit to this file without receiving review from + * webstats@FreeBSD.org. + */ + +/* Teach jslint the appropriate style rules. */ +/*jslint browser:true*/ + +var enable_ga = true; +var allow_track = true; + +var h = document.location.hostname; +/* + * Check that the hosting domain is actually a FreeBSD.org domain, so + * we don't accidentally obtain data from mirrors. + */ +var fbsdregex = /((docs|security|svnweb|cgit|wiki|www)\.freebsd\.org|google\.com)$/i; + +if (typeof navigator.doNotTrack !== "undefined" && (navigator.doNotTrack == "yes" || navigator.doNotTrack == "1")) { + allow_track = false; +} + +if (enable_ga && allow_track && fbsdregex.test(h)) { + var _gaq = _gaq || []; + _gaq.push(['_setAccount', 'UA-22767463-1']); + _gaq.push(['_setDomainName', 'freebsd.org']); + _gaq.push(['_setAllowHash', false]); + _gaq.push (['_gat._anonymizeIp']); + + /* + * If we ever want to track sites other than FreeBSD.org, + * uncomment the next line. + */ + //_gaq.push(['_setAllowLinker', true]); + // This is what we track + _gaq.push(['_trackPageview']); + _gaq.push(['_trackPageLoadTime']); + + ( function() { + var ga = document.createElement('script'); + ga.type = 'text/javascript'; + ga.async = true; + ga.src = 'https://ssl.google-analytics.com/ga.js'; + var s = document.getElementsByTagName('script')[0]; + s.parentNode.insertBefore(ga, s); + + })(); + +} + diff --git a/website/themes/beastie/layouts/partials/site-head.html b/website/themes/beastie/layouts/partials/site-head.html index 11f858b53d..934dafe12d 100644 --- a/website/themes/beastie/layouts/partials/site-head.html +++ b/website/themes/beastie/layouts/partials/site-head.html @@ -16,4 +16,6 @@ <link rel="search" type="application/opensearchdescription+xml" href="{{ absLangURL ($.Site.BaseURL) }}opensearch/ports.xml" title="FreeBSD Ports and Packages Collection"> <link rel="search" type="application/opensearchdescription+xml" href="{{ absLangURL ($.Site.BaseURL) }}opensearch/message-id.xml" title="FreeBSD Mailing List Message-ID Search"> <link rel="search" type="application/opensearchdescription+xml" href="{{ absLangURL ($.Site.BaseURL) }}opensearch/markmail.xml" title="FreeBSD Mailing List Search by MarkMail"> + + <script src="{{ absLangURL ($.Site.BaseURL) }}js/google.js"></script> </head>
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202107012244.161MiOgR043248>