Google Analytics: Track Page View during Ajax Call
Gary Oosterhuis | August 2, 2014
You’ve probably added google analytics tracking code to the <head> section of every page of your website. This tracking code allows google to track page views and additional information when making requests for new pages, but what track a page view without loading a new page. A perfect example is when requesting data using ajax.
Google analytics allows you to push a page view even when a new page (from the browsers perspective) is not being requested.
The following code will allow you to push a page view to google . It allows you to pass a page url and a title. Both of which will appear within your Google Analytics Tracking.
'title': 'Get a Quote Popup Viewed'
The page url does not need to exist to be able to push it to Google Analytics. You can provide any url.
This code is reliant on the generic Google Analytics tracking code added to the <head> section of the site. Ensure that it exists on all pages of your site.