From 3187b5b05a2ad10b70d3817fe609d0e8673cf7d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Chai=CC=88b=20Martinez?= Date: Fri, 2 Nov 2018 14:55:59 +0100 Subject: [PATCH] Add Matomo tracking code --- app/views/layouts/_matomo.html.haml | 15 +++++++++++++++ app/views/layouts/application.html.haml | 3 +++ app/views/layouts/new_application.html.haml | 4 ++++ 3 files changed, 22 insertions(+) create mode 100644 app/views/layouts/_matomo.html.haml diff --git a/app/views/layouts/_matomo.html.haml b/app/views/layouts/_matomo.html.haml new file mode 100644 index 000000000..686be9450 --- /dev/null +++ b/app/views/layouts/_matomo.html.haml @@ -0,0 +1,15 @@ +:javascript + var _paq = _paq || []; + /* tracker methods like "setCustomDimension" should be called before "trackPageView" */ + _paq.push(["setCookieDomain", "*.www.demarches-simplifiees.fr"]); + _paq.push(["setDomains", ["*.www.demarches-simplifiees.fr"]]); + _paq.push(["setDoNotTrack", true]); + _paq.push(['trackPageView']); + _paq.push(['enableLinkTracking']); + (function() { + var u="//stats.data.gouv.fr/"; + _paq.push(['setTrackerUrl', u+'piwik.php']); + _paq.push(['setSiteId', '73']); + var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; + g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s); + })(); diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 81397c33f..5b1b9cb21 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -16,10 +16,13 @@ = javascript_include_tag 'application', defer: true, 'data-turbolinks-track': 'reload' = csrf_meta_tags + = render partial: "layouts/matomo" + :javascript DATA = [{ sentry: #{raw(sentry_config)} }]; + %body{ class: browser.platform.ios? ? 'ios' : nil } = render partial: 'layouts/outdated_browser_banner' = render partial: 'layouts/pre_maintenance' diff --git a/app/views/layouts/new_application.html.haml b/app/views/layouts/new_application.html.haml index 833127d93..46cd62ac2 100644 --- a/app/views/layouts/new_application.html.haml +++ b/app/views/layouts/new_application.html.haml @@ -21,10 +21,14 @@ - if Rails.env.development? = stylesheet_link_tag :xray + - if !current_user + = render partial: "layouts/matomo" + :javascript DATA = [{ sentry: #{raw(sentry_config)} }]; + %body{ class: browser.platform.ios? ? 'ios' : nil } .page-wrapper = render partial: "layouts/outdated_browser_banner"