You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by ct...@apache.org on 2018/03/24 19:03:18 UTC

[accumulo-website] branch master updated: Fix Google Analytics (migration to gtag.js)

This is an automated email from the ASF dual-hosted git repository.

ctubbsii pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/accumulo-website.git


The following commit(s) were added to refs/heads/master by this push:
     new ef69051  Fix Google Analytics (migration to gtag.js)
ef69051 is described below

commit ef690512a5e9d8e9f2c42f983f4b411768e50517
Author: Christopher Tubbs <ct...@apache.org>
AuthorDate: Sat Mar 24 15:00:17 2018 -0400

    Fix Google Analytics (migration to gtag.js)
    
    Fix Google Analytics click event handler for download links, which were
    broken after the migration from analytics.js to gtag.js
    
    This repairs the sending of the click event for downloads to Google
    Analytics.
---
 pages/downloads.md | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/pages/downloads.md b/pages/downloads.md
index 89c06bb..961c071 100644
--- a/pages/downloads.md
+++ b/pages/downloads.md
@@ -9,7 +9,7 @@ permalink: /downloads/
 * This function takes a valid URL string as an argument, and uses that URL string
 * as the event label.
 */
-var gaCallback = function(event) {
+var gtagCallback = function(event) {
   var hrefUrl = event.target.getAttribute('href')
   if (event.ctrlKey || event.shiftKey || event.metaKey || event.which == 2) {
     var newWin = true;}
@@ -17,18 +17,27 @@ var gaCallback = function(event) {
   // $(this) != this
   var url = window.location.protocol + "//accumulo.apache.org" + $(this).attr("id")
   if (newWin) {
-    ga('send', 'event', 'outbound', 'click', url, {'nonInteraction': 1});
+    gtag('event', 'click', {
+      'event_category': 'outbound',
+      'event_label': url,
+      'transport_type': 'beacon'
+    });
     return true;
   } else {
-    ga('send', 'event', 'outbound', 'click', url, {'hitCallback':
-    function () {window.location.href = hrefUrl;}}, {'nonInteraction': 1});
+    gtag('event', 'click', {
+      'event_category': 'outbound',
+      'event_label': url,
+      'transport_type': 'beacon',
+      'event_callback': function(){ window.location.href = hrefUrl; }
+    });
     return false;
   }
 };
 
 $( document ).ready(function() {
-  if (ga.hasOwnProperty('loaded') && ga.loaded === true) {
-    $('.download_external').click(gaCallback);
+  // check if gtag is loaded
+  if (typeof gtag === 'function') {
+    $('.download_external').click(gtagCallback);
   }
 });
 

-- 
To stop receiving notification emails like this one, please contact
ctubbsii@apache.org.