Custom dimension to track visitors per language

I’m trying to setup tracking for our multilingual website using custom dimensions. The problem we currently have is that we can’t associate for example visitors or unique visitors as a function to which language they visit on our website which is determined by a 2 letter language code. Through the dashboard I know I can see the visit as a behavior if they visit our Ukrainian or Russian language platform and see how many pageviews we have.
However, since our platforms function very much independently with 95% of traffic coming from Google i’d like to find a way to gather unique visitors that is based on the language specific platform they visit.
My current idea is that custom dimensions could be a solution however i’m struggling to get it working and having doubts if it’s actually applicable to this situation

I’ve done the following.

  1. Created a custom variable that extracts the page language from the url.
  2. With the tag manager I have a custom tag where i set the custom dimension to the appropriate dimension. It looks like this: _paq.push(['setCustomDimension', 5,{{Language}}]);.

My hope is that I should get a custom dimension in the visitor tab that splits the for example our Ukranian and Russian visits into UA and RU. However, this is not working and what I’m seeing instead is the page url instead gets passed as variable which I find super odd.

Have I misunderstood something or how can achieve language specific visits and unique visits metric based on the url?

There’s probably something wrong with the value you’re extracting from the url.

Try with a custom JavaScript variable that extracts the lang attribute, like this:

function() {
   return(document.documentElement.lang);
}

This being said: Matome doesn’t have Visitor-scoped custom dimensions.

You can only have Visit-scope or Hit-scope.

Your use case is better IMHO with Hit based custom dim.

I had some regex that extracted the lang code from the url but clearly it wasn’t working. I’ve used your suggestion and it works :+1: Thank you :pray:

This being said: Matome doesn’t have Visitor-scoped custom dimensions.
You can only have Visit-scope or Hit-scope.

Correct me if i’m wrong but here it says Matomo do have Visitor scoped dimensions: https://matomo.org/faq/reporting-tools/common-custom-dimensions-and-how-to-create-them/

The mental gymnastics i’m struggling with is that the examples only showcase language specific metrics within the Action scope. This makes sense to gather but gathering Visitors per site language should naturally also make sense and fall within the Visitor scope.

1 Like

Unluckily, you’re wrong.

It does have “Visit Scope Dimensions” and “Action Scope Dimensions”. No “Visitor Scope Dimensions” whatsoever.

Action scope is the right tool for your use case because of the possible user journey of a User that switches language mid-Visit.

If you track language at the hit level, you’ll keep the language dimension correctly tied to user actions.

Thanks @kal for your reply. Really appreciate your support so far.

I have tried using the action scope setup the past weeks using parts of this example, https://matomo.org/faq/how-to/how-do-i-track-pages-across-multilingual-sites-or-sites-in-multiple-languages-in-matomo/. I’ve only used the following settings for my action scope tho.

However it also gives unsatisfactory results. I get the following data:

But number of actions is not a metric I’m looking for. I simply wanna get number of visits and page views, average visit duration, average actions etc per language site. Yesterday I thought I figured out when I tried segmenting my data based on the language variable but this also didn’t give the expected results. :frowning:

Action at the page level is exactly equivalent to Page Views.

In fact: Actions = Page Views + Events.

So there’s that.

Moreover, you can’t do a “Visit” report, because the custom dimension is recorded at the hit level and there’s always that use case where the user switches language mid-session.

So you cannot measure “Visits with language” this way.

But you CAN make a segment based on the custom dimension value and measure Visits and Visitors within that segment.

Only caveat is: if you sum Visit/Visitors of all segments… you’ll probably end up with a sum that’s bigger than the gross total.

That’s because the segments are slightly overlapping as said above.

Thanks again for your reply @kal :pray:

Got it. On our platform the specific use case of a visitor changing language mid-session is very very small. Fundamentally they are 2 different sites and users who change language mid session is negligible.
I understand however that catering for this “tracking scenario” separating visits based on an url “dimension” like language code is not straight forward technically from Matomo. I’ve gone through the “segmentation thread” in the past where this has been discussed and understand the rational. I was just wishing until the end that this was somehow possible without having to create a new tracking code for each language. Do you believe this is the only solution moving forward?

Uh, I’m not sure if this is what you wish to obtain but:

  1. Two segments based on exact match on two separate values of a Action-scoped custom dimension
  2. Time range selected: month (so you can get Visitor count)

As you can see, there’s both Visits and Visitors for each segment (sorry for the spaghetti screenshot! :joy:).

In my case the two segments are heavily overlapping (because of how the custdim is tracked), but the numbers are there nonetheless.

Thanks again for your suggestion but the slight overlap in metrics will simply not be good enough for us. Our traffic is 95% from Google and there is basically no user overlap between language platforms, additionally our offering is impact driven on a individual level so we need to be able to extract accurate visitor count for example.

Hi @yazz
As you wrote:

Then I think you can use visit custom dimensions for your need. If I am not wrong, the last recorded value will be the one stored in Matomo… (in case of a user change language mid session…)