Track HTML lang attribute

Hi together, I have a problem, that I can’t figure out …

On my website content is shown in German (DE) and English (EN). The user can choose either or. The Content language is coded in the HTML Tag at the beginning using the lang attribute (eg: <HTML lang="de"> or <HTML lang="en">).

I like to know the total number of page views (and others) and the numbers of page views (and others) separated by this lang-attribute.

I have Tag Manager activated and the given code of the container is implemented. I added a variable for the DOM Element to track the lang-attribute.

I can’t figure out how and where I see the tracking results.

Does anybody know how to do it?

HI, I’ve been trying to achieve exactly the same.
I created a variable based on DOM that read the attribute lang of main html tag.
However I still dont know how to use it wisely to get my stats.
Will keep you updated if I find something.

There are few possibilities.

Modify the title and make it so, that this is tracked explicit.

Modify only the tracked page title:
_paq.push(["setDocumentTitle", document.title + " - " + document.documentElement.lang]);

Use event tracking and filter the reports with segmentation.

Use Url query string and track it and filter the reports with segmentation.
/index.php?lang=en
/index.php?lang=de

Make separate Urls like
/index-en.php
/index-de.php

An absolutelly separate tracking will only solved with separate Urls and page titles.

Or use the plugin Custom Dimension (no knowledge on my side over this).
: https://matomo.org/guide/reporting-tools/custom-dimensions/

1 Like