Northern Captain
Northern Captain

Reputation: 1237

Google Analytics dimension pagePathLevel more than 4

I have very long web pages paths reported to google analytics:

/#/legends_g01/games/legends_g01_02_academy_i-170909-55/notes/1/dynamics
/#/legends_02_academy_i/games/legends_g01_02_academy_i-170912-64/notes/12/players
/#/legends_05/games/legends_05-170912-84/notes/22/players
/#/legends_g01_02_academy_i/games/legends_g01_02_academy_i-170919-78/notes/34/levels

I'm using Core API to create a query where I need to have a metric ga:users with dimension by the last path part (7th). The starting part of the path doesn't matter here and should be ignored.

So if there is ga:pagePathLevel7 then I can use

dimension: ga:pagePathLevel7 metrics: ga:users

And see the result like this:

dynamics: 34
players: 45
levels: 87

How can I do this without ga:pagePathLevel7?

Upvotes: 0

Views: 298

Answers (1)

Northern Captain
Northern Captain

Reputation: 1237

It seems that I'm the only one here with such a problem.

As I failed to find a direct solution I ended up adding custom dimensions to my google analytics. I added the dimensions for the last important path parts and changed the code on the site to supply this data together with the pageView url.

import ReactGA from 'react-ga';

export const statDimension = (dimensionName, value) => {
if(value)
  {
    let obj = {};
    obj[dimensionName] = value;
    ReactGA.set(obj);
  }
};

export const statPageView = (url, game_id, clip_num) => {
if(!url)
{
    url = window.location.hash;
}
//set game_id
statDimension(STAT_DIM_GAME_ID, game_id);
//set clip number
statDimension(STAT_DIM_CLIP_NUM, clip_num);

ReactGA.pageview(url);
return null;
};

I use react-ga npm module for submitting data to google analytics.

Now I can use custom dimensions together with filters on my urls to get stats based on the parts of the path with depth > 4.

May be that's not an elegant solution but is a working one.

Hope this will be helpful for somebody like me.

Upvotes: 1

Related Questions