Sending pageviews

Reminder: ー A pageview is when a web user visits a page (sometimes called “hit” or “pagehit”). Notably, it automatically contains the current URL of the page, the screen size, the window size and the size of the document.

Two instructions can be responsible for the launch of a pageview.

A pageview is automatically and compulsorily sent when the main tag has loaded. It is not possible to prevent this sending but it is possible to modify the sent URL. Note that the URL which is sent does not include the hash (meaning the elements appearing after the #).

Modify the sent URL

A JavaScript instruction can be executed to send an artificial pageview via the trackPageview command. This command is useful when the page changes without provoking a full reload, meaning a new loading of the main tag:

  • AJAX loading,
  • Popin opening,
  • Tabs changing,…

You just have to load the main tag.

Learn more about the main tag…

Sending an artificial pageview

Section titled Sending an artificial pageview

See Artificial pageviews

Contentsquare provides commands to modify the URL to be sent automatically by the Tag.
Use cases include passing information after the ’#’ sign, or removing Personal Data.

To override the path, use the setPath command:

<script type="text/javascript">
window._uxa = window._uxa || [];
window._uxa.push(['setPath', <PATH_TO_SEND>]);

The domain will be automatically added before, and the query after.

  • The value passed should be 255 characters maximum.

  • Do not add “#”, since fragments are considered to be anchors and all that comes after will be erased in the Contentsquare pipeline.

  • Don’t use this command to push query parameters. If you do and the initial URL already has query parameters, you will end up having a badly formed URL:

    • Initial URL:
    • Sent URL:

Let’s take the example of a Single Page Application that is using the fragment instead of the path to define the page identifier:

  • The initial URL of the page is:
  • The URL inserted in the Contentsquare database would be:
  • To fix that, we need to replace the # by something else (/__): window._uxa.push(['setPath', window.location.pathname + window.location.hash.replace('#','/__')]);
  • Resulting URL:

Modifying the query parameters

Section titled Modifying the query parameters

To override the query parameters, use the following command:

<script type="text/javascript">
window._uxa = window._uxa || [];
window._uxa.push(['setQuery', <QUERY_PARAMETERS_TO_SEND>]);

The domain and path will be automatically added before.

  • The value passed should be 255 characters maximum.
  • Do not add ”#”, since fragments are considered to be anchors and all that comes after will be erased in the Contentsquare pipeline.

Let’s take the example of a page that could be loaded with a popin displayed and we want to be able to identify it:

  • The initial URL of the page is:
  • Using setQuery: window._uxa.push(['setQuery', + '&cookies-popin=true']);
  • Resulting URL:

Verifying the sending of pageviews

Section titled Verifying the sending of pageviews

The Contentsquare Tracking Setup Assistant Chrome Extension will display each pageview sent with its URL and Custom vars.

To check the actual request that is sent, follow GET requests sent to //, with these parameters.

Parameters for which you can supply a value
urlpage URLString
cvarpCustom vars defined for this pageJSON — optional
Parameters determined by the technical environment of the configuration
pidProject IDInteger
rA random digit to avoid request cachingInteger
uuUnique user IDString
pnPage number (each pageview increments of 1)Integer
lvLast visitTimestamp
hdHit DateTimestamp
lhdLast hit dateTimestamp
snSession numberInteger
reCollection1 (standard), 3 (Session Replay) or 5 (Triggered Session Replay)
dwDocument widthInteger
dhDocument heightInteger
laUser’s browser languageString
drPrevious page URL (referrer)String
swScreen widthInteger
shScreen heightInteger
wwWindow widthInteger
whWindow heightInteger
cvarsSession’s custom varsJSON — optional
cvaruUser’s custom varsJSON — optional
vUXA tag’s number of versionsString
pvtPageview type“a” (artificial), “r” (renewal), or “n” (natural)
exIndicates if the pageview can be included in a Session ReplaySR (not included) or empty (can be included)
ucUser Consent0 (Not required), 1 (Not expressed), 2 (Granted) or 3 (Withdrawn)
uxtOngoing UXT tests, where requiredJSON — optional
uxtvTesting tag version, where requiredString — optional