mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Merge pull request #5545 from mbudm/task/matomo-tag-manager
Add configuration to enable Matomo Tag Manager
This commit is contained in:
@@ -26,6 +26,7 @@ Spree::AppConfiguration.class_eval do
|
||||
preference :bugherd_api_key, :string, default: nil
|
||||
preference :matomo_url, :string, default: nil
|
||||
preference :matomo_site_id, :string, default: nil
|
||||
preference :matomo_tag_manager_url, :string, default: nil
|
||||
|
||||
# Invoices & Receipts
|
||||
preference :enable_invoices?, :boolean, default: true
|
||||
|
||||
@@ -18,6 +18,10 @@
|
||||
= label_tag(:matomo_site_id, t('.matomo_site_id')) + tag(:br)
|
||||
= preference_field_tag("preferences[#{:matomo_site_id}]", Spree::Config[:matomo_site_id], type: Spree::Config.preference_type(:matomo_site_id))
|
||||
|
||||
.field
|
||||
= label_tag(:matomo_tag_manager_url, t('.matomo_tag_manager_url')) + tag(:br)
|
||||
= preference_field_tag("preferences[#{:matomo_tag_manager_url}]", Spree::Config[:matomo_tag_manager_url], type: Spree::Config.preference_type(:matomo_tag_manager_url))
|
||||
.warning.note= t('.config_instructions_tag_manager_html')
|
||||
|
||||
.form-buttons{"data-hook" => "buttons"}
|
||||
= button t(:update), 'icon-refresh'
|
||||
|
||||
@@ -1,6 +1,15 @@
|
||||
|
||||
- if Spree::Config.matomo_tag_manager_url.present?
|
||||
:javascript
|
||||
var _mtm = _mtm || [];
|
||||
_mtm.push({'mtm.startTime': (new Date().getTime()), 'event': 'mtm.Start'});
|
||||
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
|
||||
var u="#{Spree::Config.matomo_tag_manager_url}";
|
||||
g.type='text/javascript'; g.async=true; g.defer=true; g.src=u; s.parentNode.insertBefore(g,s);
|
||||
|
||||
- if Spree::Config.matomo_url.present?
|
||||
:javascript
|
||||
var _paq = _paq || [];
|
||||
var _paq = window._paq || [];
|
||||
_paq.push(["setDocumentTitle", document.domain + "/" + document.title]);
|
||||
_paq.push(["setCookieDomain", "*.#{Spree::Config.site_url}"]);
|
||||
_paq.push(["setDomains", ["*.#{Spree::Config.site_url}"]]);
|
||||
@@ -8,8 +17,8 @@
|
||||
_paq.push(['enableLinkTracking']);
|
||||
(function() {
|
||||
var u="#{Spree::Config.matomo_url}";
|
||||
_paq.push(['setTrackerUrl', u+'piwik.php']);
|
||||
_paq.push(['setTrackerUrl', u+'matomo.php']);
|
||||
_paq.push(['setSiteId', '#{Spree::Config.matomo_site_id}']);
|
||||
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);
|
||||
g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
|
||||
})();
|
||||
|
||||
@@ -415,8 +415,10 @@ en:
|
||||
title: "Matomo Settings"
|
||||
matomo_url: "Matomo URL"
|
||||
matomo_site_id: "Matomo Site ID"
|
||||
info_html: "Matomo is a Web and Mobile Analytics. You can either host Matomo on-premises or use a cloud-hosted service. See <a href='http://matomo.org' target='_blank'>matomo.org</a> for more information."
|
||||
matomo_tag_manager_url: "Matomo Tag Manager URL"
|
||||
info_html: "Matomo is a Web and Mobile Analytics application. You can either host Matomo on-premises or use a cloud-hosted service. See <a href='http://matomo.org' target='_blank'>matomo.org</a> for more information."
|
||||
config_instructions_html: "Here you can configure the OFN Matomo integration. The Matomo URL below should point to the Matomo instance where the user tracking information will be sent to; if it is left empty, Matomo user tracking will be disabled. The Site ID field is not mandatory but useful if you are tracking more than one website on a single Matomo instance; it can be found on the Matomo instance console."
|
||||
config_instructions_tag_manager_html: "Setting the Matomo Tag Manager URL enables Matomo Tag Manager. This tool allows you to set up analytics events. The Matomo Tag Manager URL is copied from the Install Code section of Matomo Tag Manager. Ensure you select the right container and environment as these options change the URL."
|
||||
|
||||
customers:
|
||||
index:
|
||||
|
||||
Reference in New Issue
Block a user