Tracking Total Pageviews By Post Type In Google Analytics

Question

I want to be able to setup a graph/table in Google Analytics that will let me see how many views I am getting by post type. So for example, I want to know the total number of views on reviews, news, guides etc.

From what I can gather, this is something you can do using a custom dimension. I setup a custom dimension in GA for this and I have added the following code after the analytics code in the head of my web page.

window.dataLayer.push({'event': 'pageview', 'dimension2': 'news', 'dimension3': 'site 3'});

My thinking here is that when someone views a post, this code will ensure +1 is added to the total for news so i can find out the total number of views.

I saw some other guides say to do it via gtag but this has not worked either.

gtag('event', 'view', {'pType': 'news', 'site': 'site 3'});

Has anyone been able to get this working?

0
user1889580 1 month 2022-10-24T15:30:26-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse