For some reason my product names looks really strange in Google analytics, when fetching data from my Magento2 installation.

For instance GEAR\u0020H\u00E5ndmixer\u0020Olivia\u00201.0\u0020Rosa when the real name in magento (and also in the database) is GEAR Håndmixer Olivia 1.0 Rosa

Any idea how to fix this?


Your product isn't UTF-8 friendly, try adding following setting to your Google Analytics

ga('set', 'encoding', 'UTF-16'); // or UTF-8

More details can be found at https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#encoding

  • Thanks for the reply Adnan, but my site should be UTF-8? I got the following in my header <meta charset="utf-8"> Also page titles seems to be encoded correctly.. just the products that's all weird for some reason. – Michael Dec 10 '17 at 20:48
  • Did a little more digging, and seems like the name is wrong even before being passed to analytics. in the ga.php file, it calls this function $this->escapeJs($item->getName()) and the return here, also contains the weird product name. Maybe I can replace this call with a better one? – Michael Dec 11 '17 at 12:45
  • This function 'escapeJS' is normally escapes unprintable (non utf8) characters, give it a try and replace this call with better one. – Adnan Dec 11 '17 at 19:46
  • @Michael yes you are right but I am talking about GA, sometimes we have to tell GA that treat all values with different encoding, you may try both solution, first replace escapeJS with suitable one or add encoding in GA. – Adnan Dec 11 '17 at 19:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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