Last Updated: February 25, 2016
·
691
· hanzo

Use correct New Array syntax around custom page view tracking in Google Analytics

If you are using Google Analytics on your site, and you have code that tracks custom pages, events, etc., take care when placing your square brackets (ie. New Array syntax) around parameters:

INCORRECT

_gaq.push(['_trackPageview'], '/mycustompage.htm');

CORRECT

_gaq.push(['_trackPageview', '/mycustompage.htm']);

Incorrectly placing the square brackets is a common error and will fail silently due to the nature of how Google's Analytics JS library is dynamically inserted into the document.