Skip to content

Session Attributes

Session attributes are a pre-defined and persistent values stored for the duration of a visitors session, unless subsequently updated by an event. Session attributes are very useful for storing data for referencing by events at any point during the session, for example:

  • Interest, Fraud, Frustration, Engagement score: 75
  • Basket product name: Teal T-Shirt Motorcycle Print
  • Latest SKU capture: SC-1971
  • Order number: UK-1254-001AGB

Session attributes types

  • Non-editable System defined session attributes. These attributes are available for use in generating events through the Event Manager.
  • or, Custom or user-defined session attributes. Each custom attribute is assigned an internal index number, which corresponds to the first available system slot (0 - 63).

Tips

  1. Assigning and updating a session attribute is only available through an events action
  2. Session attribute values are strings with a maximum length of 255 characters
  3. Session attributes are indexed automatically
  4. System defined attributes cannot be modified

Session attributes can be configured to hold string by default, or numeric values. However, you can use Advanced mode to convert the string to a numeric type and perform operations on it.

Using attributes

Session attributes may be used in:

  • Event conditions or values
  • Dimension values
  • Session List Templates

Populating attributes

Session attributes are populated by storing event values. Whenever the event occurs, the event value can be written to a specified session attribute.

A custom or user-created session attribute may be populated by the output of multiple events. Populating the attribute with a value that is not directly available to the event(s), for example a Yes / No, True / False or Social / Email, the event requires populating but manipulated through a scripted advanced event.

The example show below shows setting the $S.CustomVar34 Fact output to either Discounted or Not Discounted depending upon value.

// Generated by Discover Event Manager
// NOTE: Do not change event name
function CUST$E_DISCOUNTED__638802292476456004()
{
    if (($S.CustomVar34.toUpperCase() != ""))
    {
        // Set fact for Report Group: No Dimension Report Group
        $F.setFact("CUST.F_E_DISCOUNTED__638802292476456004", $S.CustomVar34);
    }
}
// Generated by Discover Event Manager
// NOTE: Do not change event name
function CUST$E_DISCOUNTED__638802292476456004()
{
    if (($S.CustomVar34.toUpperCase() != ""))
    {
        // Set fact for Report Group: No Dimension Report Group
        $F.setFact("CUST.F_E_DISCOUNTED__638802292476456004", Discount Applied);
    } else 
    {
        (($S.CustomVar34.toUpperCase() == ""))
        // Set fact for Report Group: No Dimension Report Group
        $F.setFact("CUST.F_E_DISCOUNTED__638802292476456004", No Discount);
    }
}

Setting Facts

All setFact statements must record the same value. A setFact statement is what will be written as the value for each report group. If no additional report group are specified only the default No Dimension Report Group is shown.

Session attribute assignments are managed through the More Options step of the event definition. When the event occurs, the detected value for the event can populate any of the defined session attributes.

That variable and its value are added to the session object, which means it becomes part of the session data. As soon as the variable is created, it is part of the session, regardless of whether the session is active or completed.

Events can be triggered in the following points of a session:

Event Description
First Hit of Session When the session begins
Every Hit When the hit loads
After Every Hit When the hit is unloaded
Last Hit The last hit of the session
End of Session When the session closes
Last ScreenView of Session Always holds the URL, or screen view name, of the page that is currently visible

Session attributes populated by system

In the Session Attributes tab, some of the listed attributes are identified as Populated by System. These attributes are defined within the Canister and cannot be edited or viewed. These attributes are provided by Discover and do not count against the 64 session attributes available.

How session attributes are stored

Session attribute values are stored as text data. This method of storage has several implications.

  • When specifying search terms, you cannot use comparative operators on session attribute data. A text value for a session attribute cannot be specified as "greater than" another text value, for example.
  • By default, in the search interface, characters that are not indexed are removed from the inputs, which includes punctuation such as , and . and $.

Numeric data

  1. Store values as non-negative integers
  2. Do not include any punctuation
  3. Consider storing values as a range of values in different attributes
  4. When performing a search for these values, use the like operation

Practice