Custom segmentation of traffic

It's crucial in analytics that we segment the data by different criteria - so later you can observe it from many different angles.

Keytiles comes with lots of built in segmentations e.g. different eventTypes, UserAgent used by the visitor (mobile/desktop browser or native apps), tileType (content type) received traffic or even the content structure parts etc. Which is cool however there are scenarios when you need / want to implement your own segmentation.

To achieve this Keytiles supports use of "custom tags" in hit collection time. By using your own custom tags over your website content you can segment your website traffic the way you need it.

Content of this page

What are these "custom tags"?

Tags themselves are basically words. Strings. Any. Which when an Event generated by your visitor is sent into Keytiles can be tagged with.

Let's take an example!

Probably that's the easiest way.

Let's assume that you want to "color" your articles (content) on your website. (Whatever colors will mean for you...)

You come up with colors like red, blue, green and yellow . When you create a content then you can assign these tags to them.

To make things a bit more complicated, let's assume that it is possible that a specific article can actually pick up not just one but two colors - sometimes...

And of course you want to be able to check your website traffic based on this so you want answers for questions like

  • "How much traffic was on blue articles in the past 1 hour?", or
  • "How much traffic happened on red and yellow articles yesterday?", or
  • even a bit more tricky question "How many times spent visitors more than 1 minute* reading the green articles?"
    * this involves custom events which you can easily define - check our related article about how you can setup micro conversions in Keytiles.

So assume you have the following content and "coloring":

  • article-1 - blue
  • article-2 - red
  • article-3 - yellow and red
  • article-4 - blue and green

What should I do?

Step 1 - Tag the Events sent to Keytiles

First thing you need to do is to change the tracking in your website and let Keytiles know about these tags. You will basically tag the Events sent to Keytiles with the above colors.

How to change the tracking? You have options here and it depends on how you implemented it.

But basically what you need to achieve is - somehow - that you start using the primaryTags hit attribute.

  • If you are sending in hits programmatically using own JavaScript code in your website
    then before you invoke the trackEvent() method you need to make sure that the hitOptions you pass to the method has the entry primaryTags!

    For example:
    var hitOptions = {
      tileId: "article-4",
      // ...
      primaryTags: "blue,green"
      // ...
    };
    Of course this hitOptions is assembled (normally, right?) using the buildHitOptions() method. And this method actually also considers optionally present <meta> tags so if you use them then you don't need to do too much.
     
  • If you are using <meta> tags on your website to control tracking the simplest way
    then you only need to make sure you add kt:primaryTags meta tag to your page as well and fill it up with the tags.

    For example:
    <meta name="kt:primaryTags" content="blue,green">
    and you are done.

Step 2 - Verify that tags are really sent as they should

One way to do this is using our Website Tools which runs in you own website and helps you monitor what Events and with which attributes they were sent out from a specific content of yours.

But of course you are a web developer so probably you can find other ways to check things are really sent as they should... ;-)

Step 3 - Query the traffic - segmented

You can query the traffic Keytiles collected using our Query API using either the ../{containerId}/eventcounts or the ../{containerId}/eventcounts/tiles endpoints in it.

Here you have to important query parameters which are related to your intention.

primaryTagsOnly filter

If you want to filter for specific tags traffic you can use primaryTagsOnly filter parameter.

  • To just see traffic happened on blue articles you can send primaryTagsOnly=blue query param.
  • Or to see blue and green (any of them, list is interpreted here with OR operator) you can send primaryTagsOnly=blue,green query param.

groupBy parameter

You also have the possibility to not (just) filter but query the traffic grouped by the tags.

In this case you need groupBy=primaryTags query param.

"secondaryTags" - also available

So far in the above example we have "colored" our content. And we used primaryTags to do that. However if you check the Hit Collection API then you can realize Keytiles also supports secondaryTags.

Correct! We do. You can use this secondaryTags to segment your traffic by one more / another criteria. Something different to "content coloring" what we just used the primaryTags for. It's only up to you if you want/can use it for something or not.

Limitations

  • One tag can be max 24 characters long.
    If you exceed it the tag will be ignored and you get a warning level Hit Fault.
  • A tag can just have alphanumeric upper/lower case and "-" or "_" characters. With regexp terms must match [a-zA-Z0-9-_]+
    If you violate it the tag will be ignored and you get a warning level Hit Fault.
  • You can use maximum 3 different tags (comma separated) simultaneously in both primaryTags and secondaryTags.
    If you violate this then the overflowing tags will be simple omitted and you get a warning level Hit Fault.