1. N.Rich Knowledge Base
  2. Installing N.Rich Website Tag

Event Tracking: Sending Page Category to Analytics

You can set categories to any page on your website and use this category with N.Rich analytics. N.Rich Website tag allows two ways to perform this:

  1. Define page category using the tag configuration

  2. Define page category using Javascript on the page

For correct operation, you should use 'UTF-8' encoding on the page. Otherwise, any non-Latin symbols will be corrupted. The page category must not be longer than 75 characters.

Define page category via tag configuration

Sample of default N.Rich Website Tag code:

<script type="text/javascript">
    var config = {
      cookieless: true,
    };
    !function(n,a,t,i,f,y){n[t]=n[t]||function(){(n[t].q=n[t].q||
    []).push(arguments)},n[t].l=1*new Date,f=a.createElement(i),f.async=true,y=a.getElementsByTagName(i)[0]
    ,f.src='https://serve.nrich.ai/tracker/assets/tracker.js?'+t,y.parentNode.insertBefore(f,y)}
    (window,document,'nt','script'),nt('load','{tag_uuid}', config);
</script>
 
In the configuration block you can specify the page_category parameter to mark this page with the desired category. example:
<script type="text/javascript">
    var config = {
      cookieless: true,
      page_category: 'Automotive',
    };
    !function(n,a,t,i,f,y){n[t]=n[t]||function(){(n[t].q=n[t].q||
    []).push(arguments)},n[t].l=1*new Date,f=a.createElement(i),f.async=true,y=a.getElementsByTagName(i)[0]
    ,f.src='https://serve.nrich.ai/tracker/assets/tracker.js?'+t,y.parentNode.insertBefore(f,y)}
    (window,document,'nt','script'),nt('load','{tag_uuid}', config);
</script>

Define page category via a Javascript function call

N.rich Website Tag adds a special function to the page to perform additional actions. The name of the function is nt. You can use this function to define the page category as an alternative to using the tag configuration. This function will be available on any page including N.Rich Website Tag and may be called anywhere on the page once the page has loaded. Usage example of the function: 

nt('set_meta', 'page_category', 'Business');

The function will add the specified page category and can be called several times. If called several times, each call will update the page category to a new value. Example:

nt('set_meta', 'page_category', 'example_category1');
nt('set_meta', 'page_category', 'example_category2');
nt('set_meta', 'page_category', 'example_category3');
 
The result page category will be example_category3 as specified in the last call.

The function also will override the configuration value if specified. For example:

<script type="text/javascript">
    var config = {
      cookieless: true,
      page_category: 'Automotive',
    };
    !function(n,a,t,i,f,y){n[t]=n[t]||function(){(n[t].q=n[t].q||
    []).push(arguments)},n[t].l=1*new Date,f=a.createElement(i),f.async=true,y=a.getElementsByTagName(i)[0]
    ,f.src='https://serve.nrich.ai/tracker/assets/tracker.js?'+t,y.parentNode.insertBefore(f,y)}
    (window,document,'nt','script'),nt('load','{tag_uuid}', config);
</script>

<script>
  nt('set_meta', 'page_category', 'Business');
</script>
 
This will lead to set up page category 'Business' as specified in the function call instead of value provided via configuration.