Artificial Pageviews
Artificial pageviews (APVs) track a step that the visitor sees as a distinct view but that doesn't change the URL, such as opening a modal, popin, or overlay.
Use artificial pageviews for the following cases:
| Case | When to send the artificial pageview |
|---|---|
| Modal windows (also called popups or popins), such as a cart preview or a newsletter sign-up | When the modal opens, and again when it closes |
| Overlays, drawers, or tabs that change the content displayed without changing the URL | When the visitor opens the view, and again when they leave it |
| Key interactions you want to analyze as a separate step, such as adding an item to the cart | When the interaction happens |
To send artificial pageviews, follow the instructions for your tag manager or setup below.
Contentsquare Tag Configurator (CSTC)
Section titled Contentsquare Tag Configurator (CSTC)Use the Contentsquare Tag Configurator ↗ to implement artificial pageviews through a visual interface.
Google Tag Manager (Template)
Section titled Google Tag Manager (Template)Stable URLs
Section titled Stable URLs-
Open your container and go to the templates section

-
Select Search gallery

-
Type in
contentsquareand select the Contentsquare - Artificial Pageview option
-
Click Add to workspace

-
Confirm your choice by selecting Add

-
Go to the Tags section and click the New button to create a new tag

-
Configure it by selecting the top-right button

-
Type in
contentsquareand select the Contentsquare - Artificial Pageview option
-
Select the tag and configure:
- Select the Free text option and enter the value under
Artificial Pageview value. - If there's a modal (sometimes called "popup") on your website and you need to deploy APV, then select
This is for the opening a popuporThis is for the closing of a popupin the drop-down.

- Select the Free text option and enter the value under
Google Tag Manager (Custom HTML)
Section titled Google Tag Manager (Custom HTML)Stable URLs
Section titled Stable URLs-
Select "Choose a tag type to begin setup...".

-
In the list, pick the "Custom HTML" tag.

-
Write the snippet to be fired in the HTML field. It should be similar to this:
<script type="text/javascript">window._uxa = window._uxa || [];window._uxa.push(["setQuery",window.location.search + (window.location.search ? "&" : "?") + "cs-popin-dedicated_query_string", { lifespan: 'onNextPageviewOnly' }]);window._uxa.push(["trackPageview",window.location.pathname + window.location.hash.replace("#", "?__"), { lifespan: 'onNextPageviewOnly' }]);</script>
-
Select "Choose a trigger to make this tag fire...".

-
Create a new trigger to make this tag fire

-
Select "Choose a trigger type to begin setup...".

-
In the list, pick the "All Elements" trigger.

-
Check "Some Clicks"

-
Select "Click Element", "matches CSS selector" and enter a valid CSS filter corresponding to the element you want to track.
For example the valid CSS for:
<button class="btn btn primary">Submit</button>Will be:
.btn.btn.primary
Tealium
Section titled TealiumStable URLs
Section titled Stable URLsAssign the event you might already have in place a custom HTML snippet and write the snippet to be fired in the HTML field. It should be similar to this:
<script type="text/javascript"> window._uxa = window._uxa || []; window._uxa.push([ "setQuery", window.location.search + (window.location.search ? "&" : "?") + "cs-popin-dedicated_query_string", { lifespan: 'onNextPageviewOnly' } ]); window._uxa.push([ "trackPageview", window.location.pathname + window.location.hash.replace("#", "?__"), { lifespan: 'onNextPageviewOnly' } ]);</script>Adobe Tags
Section titled Adobe TagsStable URLs
Section titled Stable URLsArtificial Pageviews
Section titled Artificial PageviewsWhen setting up the rule, make sure to target the specific event or condition needed. For instance, for an add to bag action, you could either follow the click route:

Or the custom event route:

Once you've chosen the desired event, you can select the Artificial Pageview tracking action from the Contentsquare extension.

Depending on the pageview you'd need to track, you can either specify the query to be passed to the Contentsquare servers:

Or, leave the input field empty, which will allow our script to capture the current URL automatically:

Commanders Act
Section titled Commanders Act-
To add a new event, go to the "EDIT" step, and click "ADD EVENT" (1):

A configuration window will appear, with several fields:
- (1) "Name": Name of the event you wish to add
- (2) "Id": The event's ID (to be completed only if you know it and want to trigger the event based on its ID; otherwise, leave the field empty, and it will be generated automatically by Commanders Act)
- (3) JavaScript code: Area where the event's JavaScript code is entered
- (4) "Use Tag Cleaner": Feature allowing you to "correct" the event (rewrites it to avoid JavaScript errors and makes it compatible with the container's code)

-
Click "ADD" to add your event to the container.
-
Go to the tag library. Once there:
- Write "Event Injection" in the search engine
- Select the tag
- Add the tag

In case of tracking pageviews with Contentsquare, the code to be deployed should follow this guideline:
window._uxa = window._uxa || [];window._uxa.push(['trackPageview', <PATH_TO_SEND> ]);(4) Go to your website; place the cursor on the element you wish to place an event on and do a right click. In the menu that opens up, select "Inspect Element". (5) In the console, once the element is highlighted, right-click again. (6) Choose "copy" from the menu. (7) > "Copy Selector".

(8) If you know the element's ID (starting with a #): copy and paste it in the #CSS_PATH# field.

(9) If you do not know or cannot find the ID: copy and paste the element's information starting with "#" and replace " > " with a single space in the code line.

(10) Copy and paste the line in the interface's #CSS_Path# field.

Now enter the ID of the event you wish to summon in the corresponding field.
Proceed to the deployment step as you do with other tags.
Shopify
Section titled Shopify-
Within the main menu, select Online Store > Themes, then click the Actions drop-down menu, and Edit Code.

-
Open the relevant Liquid file where you want to trigger an artificial pageview based on your own JavaScript logic. You can put this in the main
theme.liquidfile or in a specific Liquid file.Let's say you want to trigger this artificial pageview only when a certain action takes place like when an item is added to the cart. You would need to wrap this code inside your own condition, callback function, or event listener.
-
In the snippet below, replace
<PATH_TO_SEND>with your unique path.<script type="text/javascript">window._uxa = window._uxa || [];window._uxa.push(['trackPageview', <PATH_TO_SEND> ]);</script>You either hard-code a static value for the path like
Added_to_cartor use Shopify's Liquid Objects ↗/Liquid Tags ↗ to grab the dynamic data from it like below:<script type="text/javascript">// Contentsquare Send Artificial Pageviewsdocument.getElementById("AddToCart").addEventListener('click', function() {window._uxa = window._uxa || [];window._uxa.push(["trackPageview", "Added_to_cart_" + {{ custom_tag.value}}])});</script> -
Insert this code after the main tracking tag block.
The end result of adding this code into the Liquid file:
<!-- Contentsquare Tags Start --><script type="text/javascript">// Contentsquare Main Tracking Tag(function () {window._uxa = window._uxa || [];if (typeof CS_CONF === "undefined") {window._uxa.push(["setPath",window.location.pathname + window.location.hash.replace("#", "?__"),{ lifespan: "onNextPageviewOnly" }]);var mt = document.createElement("script");mt.type = "text/javascript";mt.async = true;mt.src = "//t.contentsquare.net/uxa/769238b6e1309.js";document.getElementsByTagName("head")[0].appendChild(mt);} else {window._uxa.push(["trackPageview",window.location.pathname + window.location.hash.replace("#", "?__")]);}});</script><script type="text/javascript">// Contentsquare Send Artificial Pageviewsdocument.getElementById("AddToCart").addEventListener('click', function() {window._uxa = window._uxa || [];window._uxa.push(["trackPageview", "Added_to_cart_" + {{ custom_tag.value}}])});</script> -
To modify the entire path that is sent, use the
setPathcommand:<script type="text/javascript">// Contentsquare Send Artificial Pageviewsdocument.getElementById("AddToCart").addEventListener('click', function() {window._uxa = window._uxa || [];window._uxa.push(["setPath", "Added_to_cart_" + {{ custom_tag.value }}, { lifespan: "onNextPageviewOnly" }]);window._uxa.push(["trackPageview"]);});</script>For more information, see the
setPathcommand. -
To modify only the query string, use the
setQuerycommand:<script type="text/javascript">// Contentsquare Send Artificial Pageviewsdocument.getElementById("AddToCart").addEventListener('click', function() {window._uxa = window._uxa || [];window._uxa.push(["setQuery", "Added_to_cart_" + {{ custom_tag.value }}]);window._uxa.push(["trackPageview"]);});</script>
For more information, see the setQuery command.
Custom HTML
Section titled Custom HTMLTo send a pageview, use the trackPageview command:
<script type="text/javascript"> window._uxa = window._uxa || []; window._uxa.push(['trackPageview', <PATH_TO_SEND>]);</script><PATH_TO_SEND> is limited to 255 characters.
Stable URLs
Section titled Stable URLsFor instance, in case you wanted to keep track of the modal window appearing when adding an item to the cart:
<script type="text/javascript"> window._uxa = window._uxa || []; window._uxa.push([ "setQuery", window.location.search + (window.location.search ? "&" : "?") + "cs-popin-dedicated_query_string", { lifespan: 'onNextPageviewOnly' } ]); window._uxa.push([ "trackPageview", window.location.pathname + window.location.hash.replace("#", "?__"), { lifespan: 'onNextPageviewOnly' } ]);</script>Tracking a modal opening
Section titled Tracking a modal openingTo track a modal (or "popin") opening/closing during the user's navigation, use artificial pageviews.
-
A first artificial pageview needs to be sent when the modal is opened — the sent URL will be the current one, followed by a string of characters allowing you to identify the modal.
<script type="text/javascript">window._uxa = window._uxa || [];window._uxa.push(["setQuery",window.location.search + (window.location.search ? "&" : "?") + "cs-popin-dedicated_query_string", { lifespan: 'onNextPageviewOnly' }]);window._uxa.push(["trackPageview",window.location.pathname + window.location.hash.replace("#", "?__"), { lifespan: 'onNextPageviewOnly' }]);</script> -
A second artificial pageview needs to be sent when the modal is closed, for example on a click on the close button or on a custom JavaScript event that fires when the modal is dismissed. The sent URL will be the current one.
<script type="text/javascript">window._uxa = window._uxa || [];window._uxa.push(["trackPageview",window.location.pathname + window.location.hash.replace("#", "?__")]);</script>