Track Pageviews
To aggregate user behavior and engagement at the screen/page level, track page transitions by calling the trackPageview
command.
window._uxa = window._uxa || [];window._uxa.push(["trackPageview", "PAGE_TITLE_OR_URL"]);
The Web Tracking Tag logs a pageview event that identifies the new page with the page title that you provide.
Track pageviews differences (WebView vs Web)
Section titled Track pageviews differences (WebView vs Web)Tracking Pageviews has different rules depending on the context: in web or WebView.
No natural pageview in WebView mode
Section titled No natural pageview in WebView modeWhen set in WebView mode (isWebView
not set or set to true
), the tracking tag will not trigger (web) natural pageviews. If you rely on a natural pageview when the page is loaded from a web browser, make sure to use the trackPageview
when loaded in WebView mode.
Example:
<script type="text/javascript"> (function () { window._uxa = window._uxa || []; if (aConditionThatTellsYouWeAreInAWebview()) { window._uxa.push(['setOption', 'isWebView', true]); window._uxa.push(['trackPageview', 'PAGE_TITLE_OR_URL']); } else { // Tag will trigger a natural pageview in web context } var mt = document.createElement("script"); mt.type = "text/javascript"; mt.async = true; mt.src = "https://t.contentsquare.net/uxa/YOUR_TAG_ID.js"; document.getElementsByTagName("head")[0].appendChild(mt); })();</script>
trackPageview
command differences
Section titled trackPageview command differencesThe trackPageview
command is also used to send an artificial pageview in web context. However the page title/URL setup behaves differently:
- In WebView mode, the value you set is the one that will be seen in the Contentsquare platform (while in web context, the tag will prepend the value with the domain and append it with the query parameters).
- In WebView mode, if no value (second array element) is provided, no default value will be provided (while in web context, the tag will set the path as default value).