Google Tag Manager integration

Alex Cowell Updated by Alex Cowell

As the introduction, it's recommended to overview the following article about Google Tag Manager principles and basic setup.

To increase the integrity of Markeaze Chat and your SEO, it is recommended to perform the following changes with your website.

Basic Code:

Copy the code below and paste that before the closing </head> tag on every page of the website. The code is asynchronous, so it does not block or interfere with page loading. You can use Google Tag Manager or paste the code directly into your CMS page template.

<script type="text/javascript">

(function(w,d,c){w[c]=w[c]||function(){(w[c].q=w[c].q||[]).push(arguments)};var t = document.cookie.match(new RegExp('(^| )mkz_version=([^;]+)'));var h = 'https://cdn.jsdelivr.net/gh/markeaze/markeaze-js-tracker@'+(t&&t[2]||'latest')+'/dist/mkz.js';var s = d.createElement('script');s.type = 'text/javascript';s.async = true;s.charset = 'utf-8';s.src = h;var x = d.getElementsByTagName('script')[0];x.parentNode.insertBefore(s, x);})(window,document,'mkz');

mkz('watch', 'url.change', function() {  
mkz('trackPageView');});

mkz('appKey', 'xxxxxxxxxxxxx@us’); // App key of your account

</script>

Please replace xxxxxxxxxxxxx@us to the real app key from your account.

Additional options and events.

You can significantly expand the functionality of Markeaze if you supplement the main code with the following events and parameters. 

Please note, some basic JavaScript knowledge is required.

User data

For a registered user, please specify his identifier and some contact details.

<script type="text/javascript">

mkz('setVisitorInfo', {
client_id: <ID>, // required
email: <EMAIL>,
phone: <PHONE>,
first_name: <FIRST_NAME>,
last_name: <LAST_NAME>,
gender: <GENDER>, // male / female
date_of_birth: <DATE> // YYYY-MM-DD
});

</script>

User data Event

Install the code on each contact form. Specify some contact details.

<script type="text/javascript">

mkz('trackVisitorUpdate', {
  email: <EMAIL>,
  phone: <PHONE>,
  first_name: <FIRST_NAME>,
  last_name: <LAST_NAME>,
  gender: <GENDER>, // male / female
  date_of_birth: <DATE> // YYYY-MM-DD
});

 </script>

Category view Event

Install the code on each product category page. Specify the value of the uid field.

<script type="text/javascript">

mkz('setCategoryView', {
  uid: '<UID>', // required
  name: '<NAME>'
});

 </script> 

Product View Event

Install the code on each product page. Specify the field values: variant_id, price, name, main_image_url.

<script type="text/javascript">

mkz('setOfferView', {
  variant_id: '<VARIANT_ID>', // required
  price: <PRICE>,
  name: '<NAME>',
  main_image_url: '<IMAGE_URL>'
});


 </script> 

 

Cart change Event

The code should be installed on each button that adds, deletes or changes the number of goods in the cart. Send data on all the goods in the basket and their fields: variant_id, qnt, price.

<script type="text/javascript">

mkz('trackCartUpdate', {
  items: [
    {
      variant_id: '<VARIANT_ID>', // required
      qnt: <QNT>, // required
      price: <PRICE>, // required
      name: '<NAME>',
      url: '<PRODUCT_PAGE_URL>',
      main_image_url: '<IMAGE_URL>'
    },

    ...
  ]
});

 </script> 

Purchase Event

Install the code on the "Thank you for your purchase" page. Specify the field values: order_uid, total. Define the goods in the order and their fields: variant_id, qnt, price.

<script type="text/javascript">

mkz('trackOrderCreate', {
  order_uid: '<ORDER_UID>', // required
  total: <QNT>, // required
  payment_method: <PAYMENT>,
  shipping_method: <SHIPPING>,
  items: [
    {
      variant_id: '<VARIANT_ID>', // required
      qnt: <QNT>, // required
      price: <PRICE>, // required
      name: '<NAME>',
      url: '<PRODUCT_PAGE_URL>',
      main_image_url: '<IMAGE_URL>'
    },
    ...
  ]
});

 </script> 

 

Search Event

Install the code on the search page. Specify the value of the term field.

<script type="text/javascript">

mkz('trackSearch', {
  term: 'abc' // required
});

</script> 

How did we do?

How to add Markeaze to your Ecwid store

Contact