Implementing page view analytics
You can implement page view analytics in your application to collect citizen page views for analysis. Using the included page view JavaScript functions, you can start tracking page views by implementing a callback to send tracking data to a library of your choice for analysis. In this example, the data is sent to the Google global site tag (gtag.js) JavaScript tagging framework.
Before you begin
The registerPageViewCallback
and pageView
functions are
available for you to implement tracking in your custom application.
registerPageViewCallback
- This function takes a callback, which you must define, as an argument. You must call the
registerPageViewCallback
function before the application is rendered. pageView
- This function calls the registered page view callback where present. If the page view callback
is not registered, it is not called.For IEG pages,
pageView
passes an object with the following properties as a parameter to the callback:pageType
('IEG')pageID
(the current IEG page ID)scriptID
(the IEG script ID)
For non-IEG pages,
pageView
passes an object with the following properties as a parameter to the callback:title
location
path
About this task
When you define your own custom routes, you must use the TitledRoute
component
so that the pages can be tracked. If the route corresponds to an IEG script, you must set the
isIEG
property for the TitledRoute
component.