Fixes for Matomo

This commit is contained in:
Lars Kusch 2022-12-17 14:13:12 +01:00
parent 51b5357aed
commit 36771eedce
4 changed files with 23 additions and 9 deletions

View File

@ -9,7 +9,7 @@
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
_paq.push(['setUserId', '{{ auth()->guard('contact')->user()->company->present()->name }}']);
_paq.push(['setUserId', '{{ auth()->guard('contact')->user()->present()->name() }}']);
(function() {
var u="{{ $company->matomo_url }}";
_paq.push(['setTrackerUrl', u+'matomo.php']);

View File

@ -9,7 +9,7 @@
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
_paq.push(['setUserId', '{{ auth()->guard('contact')->user()->company->present()->name }}']);
_paq.push(['setUserId', '{{ auth()->guard('contact')->user()->present()->name() }}']);
(function() {
var u="{{ $company->matomo_url }}";
_paq.push(['setTrackerUrl', u+'matomo.php']);

View File

@ -9,7 +9,6 @@
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
_paq.push(['setUserId', '{{ auth()->guard('contact')->user()->company->present()->name }}']);
(function() {
var u="{{ $company->matomo_url }}";
_paq.push(['setTrackerUrl', u+'matomo.php']);

View File

@ -3,8 +3,23 @@
<head>
<!-- Error: {{ session('error') }} -->
@if (config('services.analytics.tracking_id'))
@if (isset($company) && $company->matomo_url && $company->matomo_id)
<script>
var _paq = window._paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
_paq.push(['setUserId', '{{ auth()->guard('vendor')->user()->present()->name() }}']);
(function() {
var u="{{ $company->matomo_url }}";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '{{ $company->matomo_id }}']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
})();
</script>
<noscript><p><img src="{{ $company->matomo_url }}/matomo.php?idsite={{ $company->matomo_id }}&amp;rec=1" style="border:0;" alt="" /></p></noscript>
@elseif (config('services.analytics.tracking_id'))
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-122229484-1"></script>
<script>
window.dataLayer = window.dataLayer || [];