0

Hi does anyone know where I can put the Clarity Tracking Code in Magentos website? Here are the steps listed below. We have the first step completed setting up the Clarity account. But not sure about step 3.

Step 2: Go to 'Setup' and copy the Clarity tracking code.

Step 3 - Paste it into the section of your website. For this you need to check where to put Clarity tracking code in Magento CMS.

Yea, I am not sure where to put this tracking code in the CMS of Magento. It does not give me directions for Magento setup, see image and tracking code below. So can this work with Magento?

I know Microsoft Clarity is a new Tracking Tool like google analytics. We have google analytics set up already. However, this tool does not make it very clear how to set up with Magneto's CMS.

https://clarity.microsoft.com/

<script type="text/javascript">
    (function(c,l,a,r,i,t,y){
        c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};
        t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i;
        y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);
    })(window, document, "clarity", "script", "");
</script>

enter image description here

Thanks for any help!

1 Answer 1

1
  • You can Log in to Magento Admin -> Content -> Configuration
  • If you have single store, there will be 3 records for Global/ Website and Store View.
  • Then Check if you have content inside "Scripts and Style Sheets" textarea under "HTML Head" tab under "Other Settings" area. This area is visible when you click on the "Edit" link from the grid for store/website and/or global level theme (inside Admin -> Content -> Configuration).
  • Paste the script given inside the text area.
  • If you have a <script type="text/javascript"> tag already, then you can either place the script without the starting and ending scripts tags or, place the entire script outside the existing script tag.
  • Do mind that the order of picking the HTML Head area is first store view then website view and finally global view. So first check on which area you have content and place your script accordingly.
  • Also make sure you add your Clarity key, inside the blank double quote ("") of this line (window, document, "clarity", "script", "")
  • Then after placing the script, after about 1-2 hours the tracking will start to appear on Clarity platform

enter image description here

enter image description here

enter image description here

2
  • Hi @rukrlf, Thank you for this detailed answer. Very helpful. Couple questions. I do not have a script tag but I do have a style tag and below that a meta tag for google site verification. Should I place the Script Tag Before the Style tag or After? Also, Do I need to flush cache or anything after Saving config? Then the last question is do I put this tag in Store view? That is where my Script Tag is right now in that section. So I believe I do put this in Store View, just wondering if before the style tags. Thanks again for your help!
    – Jonathan
    Jan 1, 2021 at 22:06
  • 1
    @Jonathan That's not an issue I guess, you can place it before or after your style tag. And yes, use it in your store view and better to flush your cache as well, I missed it.
    – rukrlf
    Jan 4, 2021 at 7:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.