Analytics
1.9K members online now
Understand information in your reports and troubleshoot reporting issues such as self-referrals, (not set) data, and inaccurate information
 
Guide Me
star_border
Reply

How to track full Pagepath for SPA?

Follower ✭ ✭ ☆
# 1
Follower ✭ ✭ ☆

For SPA, how to track full pagepath and see that in Landing Page/All Pages report? 

 

Ex: https://example.com/welcome/home.html#/dashboard

How to track - welcome/home.html#/dashboard completely?

 

Appreciate inputs on this, thanks! 

 

1 Expert replyverified_user

How to track full Pagepath for SPA?

Top Contributor
# 2
Top Contributor

Hi,

 

You need to modify your send pageview command in order to track the #anchors:

 

ga('send', 'pageview', location.pathname + location.search + location.hash);

 

Hope this helps, let me know if it works.


Arnold Majlath, Google Analytics Top Contributor
Circle Me On Google+ | Visit me @ Redfly Digital

How to track full Pagepath for SPA?

Follower ✭ ✭ ☆
# 3
Follower ✭ ✭ ☆

Hi @Arnold M,

 

Thanks for your response. Let me know if my understanding is correct: 

 

1. location.pathname returns the full path or partially? What exactly it returns from the above URL? 

2. location.hash returns the anchor portion of a URL, including the hash sign (#).
i.e.#/dashboard ?

3. location.search returns the query portion of a URL, including the question mark (?)

What does this return?

 

Please let me know what would be the output if i use - ga('send', 'pageview', location.pathname + location.search + location.hash); for the above url. 

 

Thanks,

Shashank

 

 

Marked as Best Answer.
Solution
Accepted by topic author Shashank S
December 2016

How to track full Pagepath for SPA?

Top Contributor
# 4
Top Contributor

Hi,

 

location.pathname will return /welcome/home.html
location.hash will return #/dashboard
location.search would return the query string if any

 

The full output sent to Google Analytics would be /welcome/home.html#/dashboard

 

Let me know if you have more questions.


Arnold Majlath, Google Analytics Top Contributor
Circle Me On Google+ | Visit me @ Redfly Digital

Re: How to track full Pagepath for SPA?

Follower ✭ ✭ ☆
# 5
Follower ✭ ✭ ☆

Thank you, @Arnold M.

Will execute it and let you know. 

 

How to track full Pagepath for SPA?

Follower ✭ ✭ ☆
# 6
Follower ✭ ✭ ☆

Thanks, @Arnold M

It worked. Cheers Smiley Happy 

How to track full Pagepath for SPA?

[ Edited ]
Follower ✭ ✭ ☆
# 7
Follower ✭ ✭ ☆

Hi @Arnold M,

 

I have implemented the above code, but are you sure, all the web pages in my website will be tracked?

Even the pages after logging in? 

I am not able to see the users journey in user explorer report in detail. It is reflecting till login only. 

I have checked the data using Client ID. 

 

Any info on this would be appreciated. 

 

Thanks,

Shashank

How to track full Pagepath for SPA?

Follower ✭ ✭ ☆
# 8
Follower ✭ ✭ ☆

Hi @Arnold M,

 

Which one is correct here?

 

ga('send', 'pageview', location.pathname + location.search + location.hash);

 

or 

 

ga('send', 'pageview', 'location.pathname' + 'location.search' + 'location.hash');

 

or

 

ga('send', 'pageview', 'location.pathname + location.search + location.hash');