Paul
Paul

Reputation: 227

ga('send', 'pageview', window.location.pathname);

I am trying to figure out a way to load my pages quicker by creating a variable newHREF and then using the history.pushState('', '', newHREF); to push that link to the browser after the new content is loaded. That part works fine and I am happy with that.

The problem I am having is that I am not able to track any of the new pages after the link is pushed to the browser.

I was researching Google and found that I am able to use the ga('send', 'pageview', '/newpage'); so I created a variable named pathLink and set it to window.location.pathname.

Now I want to know how to insert that pathname into the ga pageview send command.

Can someone help me out?

Thanks in advance

Upvotes: 1

Views: 3831

Answers (1)

MisterPhilip
MisterPhilip

Reputation: 2452

Just replace the your string with the variable:

ga('send', 'pageview', pathLink);

Upvotes: 1

Related Questions