Posted on Leave a comment

Matomo Analytics tags

https://developer.matomo.org/guides/tracking-javascript-guide
https://matomo.org/faq/reports/advanced-manually-tracking-ecommerce-actions-in-matomo/

Main code + pages vues (à activer sur toutes les pages)

<!-- Matomo -->
<script type="text/javascript">
  var _paq = window._paq = window._paq || [];
  _paq.push(['trackPageView']);
  _paq.push(['enableLinkTracking']);
  (function() {
    var u="//matomo.formations-analytics.com/";
    _paq.push(['setTrackerUrl', u+'matomo.php']);
    _paq.push(['setSiteId', 3]);
    var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
    g.type='text/javascript'; g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
  })();
</script>
<!-- End Matomo Code -->




<!-- Matomo -->
<script>
  var _paq = window._paq = window._paq || [];
  /* tracker methods like "setCustomDimension" should be called before "trackPageView" */
  _paq.push(['trackPageView']);
  _paq.push(['enableLinkTracking']);
  (function() {
    
    /* tracker original
    var u="//matomo.formations-analytics.com/";
    _paq.push(['setTrackerUrl', u+'matomo.php']);
    _paq.push(['setSiteId', '3']); */

    /* ajout d'un second tracker car site déjà suivi par un premier tracker Matomo */
    var secondaryTrackerUrl = "https://matomo.formations-analytics.com/";
    var secondaryWebsiteId = 3;
    _paq.push(['addTracker', secondaryTrackerUrl+'matomo.php', secondaryWebsiteId]);
       
    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>
<!-- End Matomo Code -->

Event

<script>
_paq.push(['trackEvent', 'eventCategory', 'eventAction', 'eventName']);
</script>

Event e-commerce

// Push Product View Data to Matomo - Populate parameters dynamically
_paq.push(['setEcommerceView',
    "0123456789", // (Required) productSKU
    "Ecommerce Analytics Book", // (Optional) productName
    "Books", // (Optional) categoryName
    9.99 // (Optional) price
]);

// You must also call trackPageView when tracking a product view 
_paq.push(['trackPageView']);
// An addEcommerceItem push should be generated for each cart item, even the products not updated by the current "Add to cart" click.
_paq.push(['addEcommerceItem',
    "0123456789", // (Required) productSKU
    "Ecommerce Analytics Book", // (Optional) productName
    ["Books", "Best sellers"], // (Optional) productCategory
    9.99, // (Recommended) price
    1 // (Optional, defaults to 1) quantity
]);

// Pass the Cart's Total Value as a numeric parameter
_paq.push(['trackEcommerceCartUpdate', 15.5]); 

Custom dimension (5 max – extensible via ligne de code )

./console customdimensions:add-custom-dimension --scope=action --count=5
<script>
_paq.push(['setCustomDimension', customDimensionId = 1, customDimensionValue = 'Member']);

_paq.push(['trackPageView']);
</script>

User ID

<script>
_paq.push(['setUserId', 'USER_ID_HERE']);

_paq.push(['trackPageView']);
</script>

Domaine et sous-domaines

_paq.push(['setSiteId', 1]);
_paq.push(['setTrackerUrl', u+'matomo.php']);

// Share the tracking cookie across example.com, www.example.com, subdomain.example.com, ...
_paq.push(['setCookieDomain', '*.example.com']);

// Tell Matomo the website domain so that clicks on these domains are not tracked as 'Outlinks'
_paq.push(['setDomains', '*.example.com']);

_paq.push(['trackPageView']);
Posted on Leave a comment

Tags Facebook

https://developers.facebook.com/docs/meta-pixel/reference

Main tag + pageView

<!-- Facebook Pixel Code -->
<script>
  !function(f,b,e,v,n,t,s)
  {if(f.fbq)return;n=f.fbq=function(){n.callMethod?
  n.callMethod.apply(n,arguments):n.queue.push(arguments)};
  if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
  n.queue=[];t=b.createElement(e);t.async=!0;
  t.src=v;s=b.getElementsByTagName(e)[0];
  s.parentNode.insertBefore(t,s)}(window, document,'script',
  'https://connect.facebook.net/en_US/fbevents.js');
  fbq('init', '123456789');
  fbq('track', 'PageView');
</script>
<noscript>
  <img height="1" width="1" style="display:none" 
       src="https://www.facebook.com/tr?id={your-pixel-id-goes-here}&ev=PageView&noscript=1"/>
</noscript>
<!-- End Facebook Pixel Code -->

Évènements standards

fbq(
  'track', 'Lead', {
    content_name: 'Auto Insurance',
    content_category: 'Quote',
    value: 40.00,
    currency: 'USD'
  }
);

fbq(
  'track', 'ViewContent', { 
    content_type: 'product',
    content_ids: ['1234'],
    content_name: 'ABC Leather Sandal',
    content_category: 'Shoes'
    value: 0.50,
    currency: 'USD'
  }
);

fbq(
  'track', 'Search', { 
    search_string: 'leather sandals',
    content_category: 'Product Search',
    content_ids: ['1234', '2424', '1318', '6832'],
    value: 0.50,
    currency: 'USD'
  }
);

fbq('track', 'AddToCart', {

content_name: leather sandals,
content_ids: ['1234'],
content_type: 'product',    
value: 50.00,
currency: 'USD'

fbq(
  'track', 'Purchase', { 
    content_type: 'product',
    contents: [
      { 'id': '1234', 'quantity': 2, },
      { 'id': '4642', 'quantity': 1, }
    ],
    value: 25.00,
    currency: 'USD'
  }
);

fbq(
  'trackCustom', 'CUSTOM-EVENT-NAME', {
    custom_parameter: 'ABC',
    value: 10.00,
    currency: 'USD'
  }
);