PushState and AJAX can be used in tandem to deliver content without requiring the entire page to refresh, providing a better user experience. The other week, Richard Baxter dove into the implications of pushState for SEO on Builtvisible. If you’re not familiar with pushState, you should spend some time to read through his post.
If you're not familiar with delivering content this way, you can check out these sites using pushState and AJAX to deliver content:
Time: When you scroll to the bottom of the article, a new article loads and the URL changes
Halcyon: When you click on a navigation link, the left hand panel doesn't refresh
While pushState is really cool and great for UX, there are analytics issues presented by this technology.
How to tell if you're having tracking problems
If you have a very high bounce rate or are generally curious to check if this is a problem for you, start by installing the GA Debugger extension for Chrome. Then go to the URL you want to investigate and open up the console (windows: control + shift + j, mac: command + option + j). Now, clear the console using the button at the left, and refresh the URL.
Once you refresh the page, you should see GA debugging show up in the console. To check that the initial page view is being tracked, you should see a “sent beacon” for a pageview.
Capturing these pageviews with GTM
Start by creating a new “History Listener” tag. Now set your fire rules to all pages and hit save. This will simply look for changes to the URL.
If you already run Google Analytics from GTM, you’ll simply need to modify your existing tag. This tag should, by default, be set to track pageviews.
The firing rule for all pages should be a default option.
If you are already running GA via GTM, you’ll already have this set up. You’ll need to create a subsequent firing rule to fire a pageview for this URL History Listener.
To do this, click to add a new firing rule and then select “create new rule.” Name the rule, and then move on to conditions. The default rule should be [url] [contains]; we need to change this to [event] [equals]. Then we’ll set the condition to gtm.historyChange. Now click save.
Now you should be all set to hit publish on your updated tag container. Overnight, you should see a change in your pageviews and related metrics.
That is pretty nifty. While the cases are fairly different, a developer friend hipped me to GA tracking with CSS only. Of course, it's a little wonky, but it might be something you can bolt on to something later.
Hey Travis, thanks for the link. That's a really cool idea and can definitely see that being useful in the future.
Thank you for sharing. It was very useful to bring back my lost page views after implementing ajax.
I have seen different posts on this topic but none so complete and so well explained, thank you very much
I tried the trick that you recommended to see if I have problems tracking problems. It's fun work!
Thank you very much!
Thank you so much for guiding us how to recover the page view and prepared new strategy.
Very common issue, I've came across it at least twice in the last few months. Especially when you have microsites dedicated to a one off campaign that are not covered into the on-going SEO activities.
Having this done properly as you suggest it's key not only for SEO but also for other channels as usually microsites are heavily promoted by paid advertising.
Tracking is fundamental to prove you are doing a good job, GREAT POST! Perfectly fits into the post on Builtvisible about Infinite Scroll.
Thanks Fabrizio - I've been seeing this pop up more frequently as well recently. While I'm glad we're able to track this, it's a bit frustrating when so much effort goes into design and no thought is given to tracking on the front end of the project.
Hey Geoff,
Thank you for writing this precised useful piece. It's really been a problem for most of the marketers as companies are adopting new web technologies everyday and we have to be their mentors in whole transition process.
Honestly speaking, I didn't have the idea how to track pushsate events. I'll surely gonna implement it and will get back to you if I need anything. Will it be okay? :)
Thanks,
Hello
PushState and Ajax are fundamentally very useful for better user experience. These are useful for content sharing sites as well as ecommerce. It is really a good idea building an ecommerce store with pushstate which does not have so many products. That create really nice user experience.
But at the same time threat of wrong analytics data is always there and your post really solves that problem George. Thanks a lot for sharing this wonderful experience. This is really really useful.
Thanks
Prashant