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 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 mode

When set in WebView mode, the tracking tag will not trigger 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 || [];
var my_tag_id = YOUR_WEB_TAG_ID;
if (loadedInAWebview()) {
window._uxa.push(['setOption', 'isWebView', true]);
window._uxa.push(['trackPageview', 'PAGE_TITLE_OR_URL']);
my_tag_id = YOUR_WEBVIEW_TAG_ID;
} 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/${my_tag_id}.js";
document.getElementsByTagName("head")[0].appendChild(mt);
})();
</script>

trackPageview command differences

Section titled trackPageview command differences

The 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).