I have a basic GA setup on my SPA and the page views are working. However, I want to check the page views against an id in the URL:

If my url is www.example.com/view/?id=xyz

I would like to see the reports per xyz (a document id) and the user on xyz.

Is that possible?

  • Clarification questions: Can the same ID be on multiple URLs? What do you mean by "the user on XYZ"? – Reve Apr 3 at 15:10
  • @Reve ID is unique. I suppose each ID is a page - actually the only page. I am tracking virtual page views within the ID. If www.example.com/view/?id=xyz is a specific page, I want to track all the virtual page views per XYZ and also group page views by user viewing XYZ – zer0 Apr 3 at 15:27
  • What kind of URLs do the virtual page views get assigned? – Reve Apr 3 at 17:34
  • @Reve I set up something like ReactGA.ga('send', 'pageview', '/slide-'+(this.props.id+1)); where (this.props.id+1) resolves to a number. So, I see "pages" like "/slide-1" or "/slide-2" – zer0 Apr 3 at 17:37
  • These are fired for every click of a slide. – zer0 Apr 3 at 17:55

I think you will get the best data by editing your virtual pageviews' URLs. Unless you need to see analytics for all instances of /slide-1 together, I would recommend adding the ID as a "parent directory" of the VPV path: /XYZ/slide-1.

The major advantage of that approach is that you can use the wonderful Content Drilldown report (under Behavior > Site Content). Each ID will show on a line and you can see their total slide pageviews there, or click into each to see how many pageviews each individual slide received.

Getting at user-specific data in GA is intentionally difficult, for privacy reasons. You can look through the User Explorer under Audience to get some sense, but there isn't a way to look at an individual user's visits in the standard reports.

For some aggregate user information, as well as to work with your historical data, you'll want a segment.

For historical data, define your segment in the Conditions tab of the segment builder, reached by clicking Add Segment and then Create Segment. You can filter sessions to only those including a hit of type "Page contains id=XYZ."

Screenshot of segment builder Conditions tab with filter "Page contains id=XYZ"

Once this segment is applied, pageviews of slides will only count those that within a session that included a pageview of the "parent" page. If you have been sending virtual pageviews only, a possibility that just occurred to me, there may not be a way to separate slide pageviews per document.

By changing the segment definition to filter Users instead of Sessions, you can see what other documents have been viewed by visitors who viewed XYZ. I suspect from your comments that that is the sort of user information you are interested in anyway, so hopefully that suffices.

| improve this answer | |
  • Prefixing the id to the slides is a great idea. Thank you! I get the segmentation part but I am not sure if that will work for me. I will look into it further. Thank you so much :) – zer0 Apr 3 at 19:59

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.