Analytics provides a set of building blocks for analytics that you can apply in various scenarios to compute dynamic properties. By combining these blocks, you can create complex computations. For instance, you can define a derived column or specify an inline cohort within a retention exploration.
The block editor lets you define blocks based on computed properties. Its power comes from a comprehensive collection of pre-built blocks and the adaptability to combine blocks in various ways to meet diverse analytic needs.
Certain exploration templates and interfaces in Analytics use blocks to enhance their analytic capabilities. While the appearance of the block editor may vary slightly in these contexts, the underlying block library and its functionality remain consistent.
Block editor in derived columns, cohorts, and metrics
Derived columns, cohorts, and metrics are examples of catalog entities that represent computed properties. You define each of these entities within Analytics using the block editor. You can access the editor interface when you start the workflow to create entities.
Block editor in exploration templates
Exploration templates in Analytics let you derive computed properties directly within the template. You do not need to define and save a computed property in the catalog beforehand, such as a derived column, cohort, or metric. Instead, you can define the computed property within the template context, use it, and save it along with its definition.
Within the exploration template user interface, you can access the block editor in several ways.
-
Inline segments – Click Add Cohort > Add Block within the Segments section.
-
Computed properties – Use blocks to define computed properties for filtering or as first-class attributes, such as segmentation. You can expand and collapse the block editor. Within this UI, you can access blocks used by the exploration template. These blocks may depend on other blocks within the same template but not on blocks from other exploration templates, as those are not first-class catalog entities.
Block editor actions
The block editor supports the following actions:
Add block
Click + or Add Block and select the desired block type to include it in the definition.
Delete
Click More (⋮) > Delete.
Duplicate
Click More (⋮) > Duplicate.
Rename a block
By default, the block editor generates a name for each block. Click edit and enter a name.
Validate
Analytics automatically validates your block definitions and highlights any errors in the blocks. Errors are indicated by an error message or by displaying the block in red.
Output designation
You may see an output toggle in the block editor. Activate this toggle for at least one block to designate it as the computation's overall output. This functionality is limited to derived columns, cohorts, and metrics.
Block library
Regardless of how you access the block editor, you have a comprehensive library of diverse blocks available. Combine these blocks to perform complex computations. This section lists block categories and their corresponding inputs.
Aggregate block
An aggregate block summarizes a property or block by applying an aggregation function to the input property and potentially organizing the results into groups.
Use the following fields to configure the block:
-
Aggregator – Choose a function to aggregate input for a block.
- avg – Compute the average of the input values.
- count – Count the total number of input values, including duplicates.
- unique count – Count the number of unique input values.
- first – Compute the first input value, determined by ordering inputs by event time.
- last – Compute the last input value, determined by ordering inputs by event time.
- max – Compute the maximum input value.
- min – Compute the minimum input value.
- sum – Sum input values.
- Input – Provide input for the aggregator block. It can be a property, block, value, or parameter.
- Group by – (Optional) Group the output of the aggregator block by specified attributes. Each attribute can be a property or a block.
Output
The aggregate block produces a numerical value. If you use the Group by option, the output may include a grouping attribute.
Alias block
Use an alias block to assign a local name to a provided input. The input is typically a catalog entity, such as a dataset or property, but it can also be a block, value, or parameter.
Use the Input field to configure the block. Specify the property to which you want to assign an alias. This can be an existing property of a dataset, such as a column or derived column, or it can be a block, value, or parameter.
Output
The output of the alias block is identical to the input property you use.
And/or block
Use an and/or block to specify conditions that yield a boolean value (true or false). You form this block by merging multiple conditions or sets of conditions using and/or operators.
Use the operator field to configure comparison operators in each condition. String comparisons are case-insensitive.
- is – Checks if the left side equals the right side.
- is not – Checks if the left side does not equal the right.
- contains – Determines if the left side string contains the right side as a substring.
- in – Verifies if the left side is present within the values on the right side.
- <, >, >=, ... – Applies mathematical operators.
Comparing properties may include catalog properties such as columns, derived columns, blocks, values, or parameters.
Output
The output of the and/or block is a boolean value.
Behavioral cohort block
Use a behavioral cohort block to select a subset of a dataset based on observed behavior and other properties of the dataset's records. Determine the behavior of a dataset's record by the events linked with the entity. Behavioral cohorts can represent complex sequences and extensively accommodate the following categories of criteria:
- Filter
- Single Behavior
- Sequence
- Group
Filter or property filter
This definition filters dataset records by their property values. The left side of the filter can reference a dataset property, such as a column or derived column, another block, or a parameter. Similarly, the right side can reference any of these or a constant value. Comparison operators used in each condition are as follows. Note that when working with string data, comparison semantics are case-insensitive.
- is – Checks if the left side equals the right side.
- is not – Checks if the left side does not equal the right.
- contains – Determines if the left side string contains the right side as a substring.
- in – Verifies if the left side is present within the set of values on the right side.
- <, >, >=, ... – Applies mathematical operators.
Comparing properties may include catalog properties such as columns, derived columns, blocks, values, or parameters.
Add single behavior
Apply a filter to the dataset to extract records associated with specific events. Use a condition to define the filtering criteria and an aggregate filter to select events that meet the specified criteria.
The condition section lets you select dataset records based on the presence or absence of a specific event. For example, you can filter records for those who performed or did not perform a checkout event. This section includes the following filters:
- Event Selector – Select specific events or broad event categories, like an event stream.
- Event Filter – Narrow your focus to a specific set of events.
-
Time Filter – Filter events by their occurrence time, with three modes.
- Relative – Define a time window based on the current date, such as the last three months.
- Absolute – Set a time window based on specific dates and, optionally, the time of day.
- Relative to Event – Filter events based on the duration between an event and a baseline event or timestamp, such as within two weeks after the first onboarding event.
Use the aggregate filter (where) to limit dataset records to those where the aggregate of matching events meets a specific condition. Apply the aggregation process to the designated property of matching events. Use operators to combine multiple aggregate filters.
Sequence
A sequence selects a dataset record if it has matching events in the specified order and meets any associated filter criteria. Each sequence stage is defined by an event selection, an optional filter, and a time filter.
- Event Selector – Select specific events or broad event categories, such as an event stream.
- Event Filter – Narrow the selection to specific events.
-
Time Filter – Filter events by when they occur. This filter has the following three modes:
- Relative – Set a time window relative to the current time, such as the last three months or all time.
- Absolute – Set a time window based on specific dates and, optionally, time of day.
- Relative to Event – Filter events based on the time between an event and a baseline event or timestamp.
Group
Compose any combination of previous criteria or other groups.
Output
The output of the behavioral cohort block is a boolean value.
Bin block
Use a bin block to assign a property to distinct bins or labels based on the range within which the property's value falls.
The bin block has two main configurations, assigning input values to bins and defining bins.
- Input value – Used to calculate the bins' output. This input may refer to a catalog property, block, or parameter.
-
Bins – Add or remove configurations for individual bins as needed. The block matches input values with the bins set in the order they display. The block uses the first matching bin if a single value maps to multiple bins. Configure each bin as follows:
- Label or bin – Name assigned to the bin.
- Start – Minimum value included in the bin (inclusive).
- End – Maximum value included in the bin (exclusive).
-
Out-of-range label – Used for input values that do not fall within any configured bins.
Output The output of the bin block is a string value.
Filter block
Use a filter block to select a specific property from input data by filtering it.
Configure the filter block with the following fields:
- Data value – Specify the property being filtered and output by this block. It can be a dataset property, such as a column, derived column, or another block.
-
Filter by – Define the filter condition for the previous data value. You can organize one or more conditions into a hierarchical structure of nested and/or conditions with unlimited levels. Use the following comparison operators, noting that string comparisons are case-insensitive:
- is – Checks if the left side equals the right.
- is not – Checks if the left side does not equal the right.
- contains – Determines if the left side string contains the right side as a substring.
- in – Verifies if the left side is present within the set of values on the right side.
- <, >, >=, ... – Applies mathematical operators.
Comparing properties may include catalog properties such as columns, derived columns, blocks, values, or parameters.
Output
This block can be used to compute a property derived from the data by the filter block. This property may take the form of a column or another block.
Formula block
Use a formula block to enter computations that utilize Analytics's formula language, NetScript. For detailed documentation on syntax and functions, see the NetScript language reference.
Output
The output of the formula block varies and depends on your formula definition.
If/then/else block
Use the if/then/else block to establish a sequence of if/else/then provisions to generate a property based on diverse criteria.
When you provide an input record, the first matched if provision generates the output. If none of the if provisions meet the conditions for a given input record, and you specify an else value, it is used. If no else value is specified, the output is null.
The if/then/else block consists of a sequence of if/then definitions, with at least one required, followed by an optional else block.
To add an if/then condition, click + > Add Condition.
Configure the block with the following fields:
-
If condition – Acts as a filter on source data, which may include properties of a dataset, such as a column, derived column, or block. Configure one or more filter conditions grouped into a hierarchy of nested and/or conditions with arbitrary depth. Use the following comparison operators (string comparisons are case-insensitive):
-
- is – Checks if the left side equals the right side.
- is not – Checks if the left side does not equal the right.
- contains – Determines if the left side string contains the right side as a substring.
- in – Verifies if the left side is present within the set of values on the right side.
- <, >, >=, ... – Applies mathematical operators.
-
- Then – Assigns the output value for data that matches the corresponding if condition. This value may include a constant value, a dataset column or derived column property, another block, or a parameter.
- Else – If none of the if conditions match the source data, the default value to output is the else value. This value can be constant, a property like a dataset column or derived column, another block, or a parameter.
Output
The output of an if/then/else block is determined by the results of the then and else portions specified within the definition.
Intervals engaged block
Use the intervals engaged block to calculate the time intervals, such as days or weeks, during which a user or other actor interacts with a product or service. This block is useful for measuring user engagement with a product, feature, new release, or experiment.
Configure the block with the following fields:
- Count of distinct time Intervals – Determine the count of unique days, weeks, or months to measure user engagement.
- Actor – Specify the actor dataset, which pertains to the entity that performed an action or demonstrated engagement.
-
Event or Action (did) – Pinpoint the particular activity of interest to demonstrate engagement. Specify "active" or "user-initiated" events instead of "passive" events like push notifications. Use the event filtering interface to refine your selection
- Event selector – Select specific events or broad event categories (event stream).
- Event filter – Filter down to a specific set of events.
-
Time filter – Filter events based on their timing.
- Relative – Filters relative to the current time, for example, the last three months.
- Absolute – Filters based on specific dates and times of day.
- Relative to event – Filters based on the relative duration between an event and a baseline event or timestamp, for example, "within two weeks after the first occurrence of onboarding."
- Frequency – Specify using the "at least" and "at most" settings to constrain the number of times the actor engages in the identified activity.
Use comparison operators in each condition (string comparisons are case-insensitive). You may include catalog properties such as columns, derived columns, blocks, values, or parameters.
- is – Checks if the left side equals the right side.
- is not – Checks if the left side does not equal the right.
- contains – Determines if the left side string contains the right side as a substring.
- in – Verifies if the left side is present within the set of values on the right side.
- <, >, >=, ... – Applies mathematical operators.
Output
The output of the intervals engaged block is a numeric value for each actor used within the block definition.
Moving aggregation block
Use the moving aggregation block to calculate a measurement across a sliding or cumulative time window. Within this block, two types of aggregation are performed: regular and hopping. Regular aggregation applies a secondary aggregation over pre-aggregated data, similar to a window function in SQL, and does not change the dimensionality of the input. Hopping aggregation directly aggregates raw data and changes the dimensionality with no SQL equivalent.
Regular aggregation
Apply a secondary aggregation to the results of an existing aggregation over a specified time window. For example, calculate daily event counts (a regular aggregate) and then apply a trailing seven-day sum using a regular moving aggregation. Here is how to create a metric that calculates the sum of total ad revenue for the current day and the preceding six days.
- Create a metric and add a Moving Aggregation block.
- Select sum as the aggregator and Total Ad Revenue as the value in the Input section.
- Choose Regular as the aggregation type under Configuration.
- Set the points before the value to six and the points after zero.
- Set the time granularity to Daily.
- Run the visualization to see the results.
Hopping Aggregation
Hopping aggregation computes metrics directly over a rolling time window without re-aggregating. For instance, if you have daily event counts, a hopping aggregation applies a seven-day trailing window that "hops" by one day at a time to calculate the same result. This method is essential for operations like rolling averages or distinct counts, which cannot be achieved with regular aggregation. The following creates an example metric to demonstrate a hopping aggregation:
- Create a metric and add a Moving Aggregation block.
- Select unique count as the aggregator and user_id as the value in the Input section.
- Select Hopping as the moving aggregation type under Configuration.
- Choose Trailing as the Window Type.
- Configure the trailing window to cover the desired duration, 7 days.
- Set the time granularity to Daily and run the visualization.
Configure the block with the following fields:
-
Metric selector – Choose from the following options:
- Cumulative – Aggregate the metric in an expanding time window.
- Rolling – Aggregate the metric over a sliding time window.
-
Aggregator – Select the function to aggregate input for a block:
- avg – Compute the average of the input values.
- count – Count the total number of input values, including duplicates.
- unique count – Count the number of unique input values.
- first – Compute the first input value, ordered by event time.
- last – Compute the last input value, ordered by event time.
- max – Compute the maximum input value.
- min – Compute the minimum input value.
- sum – Sum input values.
- Input value – Choose the input value used to calculate the moving aggregation. This may be a dataset property, such as a column, derived column, or another block.
-
Time window – Varies depending on the metric selected in the metric selector.
- Cumulative – Use a time window that is a time range over which to compute the cumulative measure.
- Rolling – Specify the number of time points before and after.
Output
The output of the moving aggregation block block is a numerical value.
Period vs. previous period block
Use the period vs. previous period block to compare a metric between the current and preceding periods.
Configure the block with the following fields:
- Measure – Select the measure for comparison. This can be a dataset property such as a column, a derived column, or a block.
-
Comparison Type (Using) – Choose one of the following options:
-
- Absolute Change – Calculate the absolute delta between the current and previous values.
- Percent Change – Calculate the change since the previous period, expressed as a percent of the previous value.
- Percent of Previous Value – Express the current value as a percent of the previous value.
-
- Periods Ago – Determine the number of periods in the past to use as a baseline.
-
Filter by – Utilize the filter by field to filter to a specific set of records before comparing the period and the previous period. Use the following comparison operators (string comparisons are case-insensitive):
-
- is – Checks if the left side equals the right side.
- is not – Checks if the left side does not equal the right.
- contains – Determines if the left side string contains the right side as a substring.
- in – Verifies if the left side is present within the set of values on the right side.
- <, >, >=, ... – Applies mathematical operators.
-
- For Each – Traverse through the elements in the dataset using this field to choose attributes and make the process more specific.
- Filter by – Add additional filters using this section.
Output
The output of the period vs. previous period block is a metric that shows the comparison result or difference between the current periods.
Previous/next value lookup
Use the previous value lookup block to retrieve the prior value of a time-ordered property, which can be an event stream or block, for an actor such as a user.
Configure the block with the following fields:
- Previous/next – Select previous or next to retrieve the value for the time-ordered property per actor.
- Time series – Choose a time-ordered block or an event stream property as an input.
-
Filter – Apply a filter to narrow to a specific set of records before applying the previous/next selector. Use the following comparison operators (string comparisons are case-insensitive):
-
- is – Checks if the left side equals the right side.
- is not – Checks if the left side does not equal the right.
- contains – Determines if the left side string contains the right side as a substring.
- in – Verifies if the left side is present within the set of values on the right side.
- <, >, >=, ... – Applies mathematical operators.
-
- Output-specific property – Choose the particular property from the preceding or subsequent matching record that should be produced as output.
- Only emit a value when there is a change – Select this option to produce a non-null value only if the preceding or subsequent value differs from the current value for the same property.
- For each – Traverse through the elements in the dataset using this field to choose attributes and make the process more specific.
Output
The output of the previous/next value lookup block is the type of the previous value property.
Property block
Use the property block to select a specific property of a dataset or block.
Configure the block with the following fields:
- Property – Column or derived column.
- Dataset or Block – Select an existing dataset or any other block defined within this context.
Output
The output of this block is the same as the selected property.
Rank block
Use a rank block to rank properties in a dataset based on a measure.
Configure the block with the following fields:
- Rank of – Select the property values that you want to rank.
- Rank by – Choose one or more ordering properties to order in ascending (ASC) or descending (DESC) order.
Output
The output produced by this block is a metric that indicates the overall position of the selected property value.
Please sign in to leave a comment.