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:

1 2 3 4 5 6 7 8 9 <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:

1 2 3 4 5 6 7 8 9 10 <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:

1 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:

1 2 3 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:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 <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.