]> _ Git - cubedesigners-v7.git/commitdiff
Add event tracking on some buttons (emails, phone, map, social, external links)
authorvincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 8 Sep 2015 09:12:24 +0000 (09:12 +0000)
committervincent@cubedesigners.com <vincent@cubedesigners.com@f5622870-0f3c-0410-866d-9cb505b7a8ef>
Tue, 8 Sep 2015 09:12:24 +0000 (09:12 +0000)
framework/application/views/helpers/FooterContact.php
framework/application/views/helpers/FooterSocials.php
framework/application/views/helpers/Realisation.php
js/common.js

index fca2e596a2c9a79acce04f270cd2421c18707173..e56fa69fca05b1e4b8c9d024372b280dcb13a7aa 100644 (file)
@@ -12,29 +12,31 @@ class Cubedesigners_View_Helper_FooterContact extends Zend_View_Helper_Abstract
 
                foreach ($bureaux as $bureau) {
 
-                       $res.='<div class="bureau" itemscope itemtype="http://schema.org/LocalBusiness">';
+                       $res .= '<div class="bureau" itemscope itemtype="http://schema.org/LocalBusiness">';
 
-                       $res.='<p class="titre" itemprop="name">' . $bureau['coordonnees']['nom'] . '<p>';
+                       $res .= '<p class="titre" itemprop="name">' . $bureau['coordonnees']['nom'] . '<p>';
 
-                       $res.='<div class="numeros">';
-                       $res.='<p itemprop="telephone">' . __('Tel') . ' ' . $this->view->linkPhone($bureau['coordonnees']['tel']) . '</p>';
+                       $res .= '<div class="numeros">';
+                       $event = array('category' => 'phone', 'action' => 'call', 'label' => $bureau['coordonnees']['tel']);
+                       $res .= '<p itemprop="telephone">' . __('Tel') . ' ' . $this->view->linkPhone($bureau['coordonnees']['tel'], null, array('data-event' => $event)) . '</p>';
                        //$res.='<p itemprop="faxNumber">' . __('Fax') . ' ' . $this->view->linkPhone($bureau['coordonnees']['fax']) . '</p>';
-                       $res.='</div>';
+                       $res .= '</div>';
 
                        //$res.= $this->view->microdataPlace($bureau['coordonnees']['adresse']);
 
-                       $res.='<div class="adresse" itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">';
-                       $res.='<p>' . __('Cubedesigners') . '</p>';
-                       $res.='<p itemprop="streetAddress">' . $bureau['coordonnees']['adresse'] . '</p>';
-                       $res.='<p><span itemprop="postalCode">' . $bureau['coordonnees']['code_postal'] . '</span> <span itemprop="addressLocality">' . $bureau['coordonnees']['ville'] . '</span></p>';
-                       $res.='<p itemprop="addressCountry">' . Zend_Locale::getTranslation($bureau['coordonnees']['pays'], 'territory') . '<p>';
-                       $res.='</div>';
+                       $res .= '<div class="adresse" itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">';
+                       $res .= '<p>' . __('Cubedesigners') . '</p>';
+                       $res .= '<p itemprop="streetAddress">' . $bureau['coordonnees']['adresse'] . '</p>';
+                       $res .= '<p><span itemprop="postalCode">' . $bureau['coordonnees']['code_postal'] . '</span> <span itemprop="addressLocality">' . $bureau['coordonnees']['ville'] . '</span></p>';
+                       $res .= '<p itemprop="addressCountry">' . Zend_Locale::getTranslation($bureau['coordonnees']['pays'], 'territory') . '<p>';
+                       $res .= '</div>';
 
-                       $res.='<div class="geoloc">';
-                       $res.=$this->view->linkGeo(__("Plan d'accès"), $bureau['coordonnees']['adresse'] . ',' . $bureau['coordonnees']['ville'] . ',' . Zend_Locale::getTranslation($bureau['coordonnees']['pays'], 'territory'), array('class' => 'but'));
-                       $res.='</div>';
+                       $res .= '<div class="geoloc">';
+                       $event = array('category' => 'map', 'action' => 'click', 'label' => $bureau['coordonnees']['ville']);
+                       $res .= $this->view->linkGeo(__("Plan d'accès"), $bureau['coordonnees']['adresse'] . ',' . $bureau['coordonnees']['ville'] . ',' . Zend_Locale::getTranslation($bureau['coordonnees']['pays'], 'territory'), array('class' => 'but', 'data-event' => $event));
+                       $res .= '</div>';
 
-                       $res.='</div>';
+                       $res .= '</div>';
                }
 
                return $res;
index 0bfad05b61a2c58c96ba2d24947876576f2a2250..d222a3b015da11619e8036a50bef26142f60a2c2 100644 (file)
@@ -11,9 +11,10 @@ class Cubedesigners_View_Helper_FooterSocials extends CubeIT_View_Helper_Abstrac
                $res = '<div class="reseaux">';
                foreach ($socials as $id => $social) {
                        $image = $this->view->imageCms($social['picto'], $social['titre'], 25, 25);
-                       $res.=$this->link($image, $social['url'], array('class' => 'social', 'data-color' => $social['color']));
+                       $event = array('category' => 'social', 'action' => 'go', 'label' => $social['titre']);
+                       $res .= $this->link($image, $social['url'], array('class' => 'social', 'data-color' => $social['color'], 'data-event' => $event));
                }
-               $res.= '</div>';
+               $res .= '</div>';
 
                return $res;
        }
index 524e5fceb8e22c7394983f7abccdaa62979fc493..00b38e846b07cf92b5c4df89311f1658c2bdb3f2 100644 (file)
@@ -30,19 +30,19 @@ class Cubedesigners_View_Helper_Realisation extends CubeIT_View_Helper_Abstract
 
                $res .= $this->imageSlideshowScroll($slides, 439, array(), array('shortcuts' => false));
                $res .= '<div class="content description">';
-        $res .= '<h1>' . $r->titre . '</h1>';
-        $res .= '<ul class="tags">';
-        $res .= '<li>' . $this->dateTime($realisation->date, Zend_Date::YEAR) . '</li>';
-        $res .= '<li>' . Cubedesigners_Util::getCategoryById($r->categories, $this->localeDefault()) . '</li>';
-        $res .= '</ul>';
+               $res .= '<h1>' . $r->titre . '</h1>';
+               $res .= '<ul class="tags">';
+               $res .= '<li>' . $this->dateTime($realisation->date, Zend_Date::YEAR) . '</li>';
+               $res .= '<li>' . Cubedesigners_Util::getCategoryById($r->categories, $this->localeDefault()) . '</li>';
+               $res .= '</ul>';
 
-        $res .= $this->markupDotclear($r->description);
+               $res .= $this->markupDotclear($r->description);
 
-        if (!empty($r->url->url)) {
-            $res .= $this->_button($r->url);
-        }
+               if (!empty($r->url->url)) {
+                       $res .= $this->_button($r->url);
+               }
 
-        $res .= '</div>';
+               $res .= '</div>';
                $res .= '</article>';
 
                return $res;
@@ -54,7 +54,9 @@ class Cubedesigners_View_Helper_Realisation extends CubeIT_View_Helper_Abstract
                if ($b['label'] == '') {
                        $b['label'] = __('Voir le site');
                }
-               return $this->linkCMS($b, array('class' => 'but'));
+
+               $event = array('category' => 'external', 'action' => 'go', 'label' => "%href%");
+               return $this->linkCMS($b, array('class' => 'but', 'data-event' => $event));
        }
 
 }
index e111d24b45f2fc541ed2266976314977bd616516..e1c85ea9c3d04fb43c8e13686b3dd19eb500c2cc 100644 (file)
@@ -1,4 +1,49 @@
 registerLoader(load_commons);
+registerLoader(load_commons_once, true);
+
+function load_commons_once() {
+
+
+    $('a[href^="mailto:"]').not('[data-event]').each(function () {
+        var email = $(this).attr('href').split(':');
+        var label = email.pop();
+        var e = {
+            category: 'email',
+            action: 'click',
+            label: label,
+            value: 1
+        };
+        $(this).attr('data-event', JSON.stringify(e));
+    });
+
+    $('a[href^="tel:"]').not('[data-event]').each(function () {
+        var tel = $(this).attr('href').split(':');
+        var label = tel.pop();
+
+        var e = {
+            category: 'tel',
+            action: 'call',
+            label: label,
+            value: 1
+        };
+        $(this).attr('data-event', JSON.stringify(e));
+    });
+
+    $(document).on('click', '[data-event]', function () {
+        var e = $(this).data('event');
+        if (e.value === undefined) {
+            e.value = 1;
+        }
+        if (e.action === undefined) {
+            e.action = 'click';
+        }
+
+        e.label = e.label.replace(/%href%/gi, $(this).attr('href'));
+
+        ga('send', 'event', e.category, e.action, e.label, e.value);
+        return true;
+    });
+}
 
 function load_commons() {
     $(window).on('cubeitresize', resize);
@@ -18,6 +63,7 @@ function load_commons() {
         return false;
     });
 
+
     // Fallback to display content in case web fonts haven't triggered the display yet
     setTimeout(function () {
         $('html').addClass('wf-active');