Storage Collision

Remember, all storage read and write operations happen in JENTIS in the context of a given account, tool, and user by design. It is not possible for a value, which you store in such variables, stored on the server side, to be exchanged or confused between users or tools. So if this same server-side variable code is executed on a different user (website visitor) or tool (once for "GA4" and once for "Facebook CAPI" the result will be per each tool once per user "true", so one tool is not affecting the others).

Determining Scopes via Variables

In the example above, we used the user ID (user_doc_id variable) to make this variable return true only once for a given user ID. This was done in reference to this.getFrontendVariable("user_doc_id") (Find the backend function reference here: Functions and Interface References) which will read the variable ID "user_doc_id" that is the user's ID with JENTIS.

Now, we can adjust this to read any ID (a session ID, transaction ID, or page ID). As long as this ID is persisted, the variable "Once per ..." will return only once "true" and for all further observations of the same value, a "false."x

So, for example, if we want to track something once per page, this would be a good starting point. Let's create a page ID that remains constant for the scope of a website. If the site is reloaded, the ID should be made anew. But as long as the user doesn't navigate, the value remains consistent. This is especially interesting for single-page applications when multiple similar events happen but with no particular order (ie, a race condition) and you want a tag to execute just once per page.

We must create a new variable, so please navigate again to the JENTIS Tag Manager: Variables section and create a new custom JavaScript variable (frontend, client-side).

The name "Once per page random value" might be a good idea. Use the following code in this variable:

function() {
    window["jentis_once_per_page_randomvalue"] = window["jentis_once_per_page_randomvalue"] || Math.round(2147483647 * Math.random());

    return window["jentis_once_per_page_randomvalue"];
}

This creates a static variable (initially a random integer value) on your global scope (window). Please remember that you may want fewer objects ("pollution") on your global scope. In that case, you'd need to adjust the code accordingly to put this random value in a better position in accordance with your page guidelines.

This variable persists the value for a given page's lifecycle (page load to unload on navigation to the following webpage). This value is reported to JENTIS to indicate a website's uniqueness.

Now update your "Once per page" variable (just renamed for this use case, but the same code as the "Once per user" variable) to read the value of your newly created frontend variable "once_per_page_random_value" (the ID of your new variable) instead of the "user_doc_id."

With all this ready, let's head to the configuration to combine all puzzle pieces.

Last updated

Was this helpful?