Create / Transform Events Server-Side
Event Creation Rules
Event Creation Rules let you automatically create or transform tracking events based on data arriving in Tracklution without changing your website code or dataLayer. You define the logic once, and Tracklution applies it to every matching event in real time.
Common use cases include remapping webhook fields to standard event fields, splitting a single event type by order source, optimizing ad platform conversions on profit instead of revenue, and filtering out test or internal orders.
Event Creation Rules is a beta feature. Rules run directly in the live event collection pipeline. Test carefully before applying rules to production traffic. See Before you start below.
Before you start
When you create your first rule, Tracklution shows a disclaimer you must acknowledge before proceeding. It covers four points you should keep in mind throughout:
- Production impact: Rules run in the live event collection pipeline. A misconfigured rule can create unexpected events, alter conversion values, or discard original events.
- No undo: Once an event is discarded or a new event is created and delivered to connectors, it cannot be reversed.
- Testing recommended: Test rules with low-traffic events or in a staging container before applying them to production traffic. See Test a rule before going live.
- Beta limitations: The feature is under active development. Behavior may change, and edge cases may not be fully handled yet.
Where to find it
Open your container, go to the Settings tab and select Event Creation Rules. This section lists all existing rules with their status, source event and output event. Use the + Create Rule button to add a new rule.
How a rule works
Each rule follows this logic:
- When a
[SourceEvent]event arrives and[conditions are met], create a new event called[OutputEvent]with[field mappings], then[keep / discard]the original event and[render / do not render]a pixel for the new event.
Rules are evaluated as soon as a matching event arrives. If conditions are not met, the rule is skipped and the original event continues as normal.
Create a rule
Start a rule
- Go to Settings → Event Creation Rules and click + Create Rule.
- If this is your first rule, read the beta disclaimer and click I understand, proceed.
- In the Rule name field, enter a descriptive name (e.g.
Revenue Purchase).
Set the trigger
In the When a ___ event arrives field, select or type the name of the source event that should trigger the rule (e.g. Purchase).
Add conditions
- Click + Add condition.
- Fill in the three parts of the condition:
- Field: e.g.
value,source_alias,webhook.revenue,webhook.source_name - Operator: choose one of the operators listed below
- Value: required for most operators. For
is one of/is not one of, separate values with commas.
- Field: e.g.
- Repeat for each additional condition. All conditions must be true for the rule to fire (AND logic).
Available operators:
equals/does not equalcontains/does not containexists/does not existis greater than/is less thanis one of/is not one of
You can also pick the ready-made conditions Is new customer or Is not new customer. They need no operator or value. See New vs Returning Customer.
To match with a regular expression, see Use regex and case sensitivity.
Name the new event
In the create a new event called field, select or type the name for the new event (e.g. Purchase, PurchasePOS, ProfitMargin).
Map fields
- Click + Add field mapping.
- Fill in the two parts of the mapping:
- Target field: e.g.
value,currency. Select one from the list or type your own. - Source expression: e.g.
webhook.revenue,webhook.revenue - webhook.cost
- Target field: e.g.
- Repeat for each field you want to set on the new event.
To clean up a mapped value before it's saved, see Find and replace.
Choose what happens to the original event
- In the Then line, choose what happens to the original event:
- keep: the original event is kept and the new event is added.
- discard: the original event is dropped and not forwarded to connectors.
- Choose whether to render a pixel for the new event:
- do not render: the new event is delivered to server-side connectors only.
- render: the new event is delivered to server-side connectors and also fires a browser pixel with the same values.
- (Optional) Select Block the new event in Event Mapping to hold back delivery while you test. Nothing is sent to connectors until you unblock the event in Settings → Event Mapping. See Test a rule before going live.
Save the rule
Click Create (or Save when editing).
Use regex and case sensitivity
contains and does not contain conditions have two toggles that control how the value is matched:
- Use pattern (
.*): Turn this on to match with a regular expression. The operator is then shown as matches or does not match. Write the pattern without slashes, for example^abc. - Match case (
Aa): Controls whether upper and lower case letters must match exactly. This is on by default. Turn it off to ignore case.
Write regex patterns without slashes. Use ^abc, not /^abc/.
An invalid pattern can't be saved.
Find and replace
Use find and replace on a field mapping to clean up the value before it's saved, for example to strip a currency prefix from value. It works on value as well as on text fields.
- Under the field mapping, click Find & replace. A new line appears: then replace [Find] with [Replace with].
- In Find, enter the text to look for. By default this is plain text: it finds exactly the text you type.
- In with, enter the replacement text. Leave it empty to remove the matched text.
- (Optional) Turn on Use pattern (
.*) to use a regular expression. In pattern mode, put( )around a part of the pattern and use$1,$2in with to insert those parts. - (Optional) Turn off Match case (
Aa) to ignore upper and lower case.
To remove find and replace from a mapping, click the trash icon on that line.
Use the built-in examples
Click Show examples to see common find and replace jobs, and click Use to fill one in:
| Example | Find (pattern) | Replace with | Input | Result |
|---|---|---|---|---|
| Remove the URL query | \?.*$ | (empty) | …/thank-you?order=1042&utm_source=meta | …/thank-you |
| Remove a prefix | ^Order # | (empty) | Order #1042 | 1042 |
| Keep only the number | [^0-9.] | (empty) | EUR 120.50 | 120.50 |
| Keep only the domain | ^https?://([^/]+).*$ | $1 | https://shop.com/cart | shop.com |
| Reorder parts | ^(.+) - Size (\w+)$ | $1 (size $2) | Blue Shirt - Size M | Blue Shirt (size M) |
value is always saved as a number, so 120.50 is stored as 120.5.
Test a rule before going live
To check a rule's output without sending data to your ad platforms, block the new event while you test:
- When creating the rule, enter an event name that doesn't exist in your container yet (e.g.
PurchaseTest2). - Select Block the new event in Event Mapping.
- Click Create and wait for matching events to arrive.
- Check the new event and its values in the Processed Data table on your container dashboard. The event is stored in Tracklution as normal; only delivery to connectors is blocked.
- When you're happy with the output, go to Settings → Event Mapping, find the new event and change block for each connector that should receive it.
The Block the new event in Event Mapping option only appears when the name in create a new event called is new: not a standard event, not an event that already exists in your container, and not the output of another rule. Rules that output an existing event name (e.g. Purchase) can't be blocked this way and go live as soon as you save them.
How blocking works:
- The event is blocked per connector, so you can unblock it for one connector at a time.
- Connectors you add later start with the event blocked.
- Connectors that require events to be mapped explicitly (conversion actions, goals etc.) are not delivered until you map the event.
Manage existing rules
In the Event Creation Rules section, each rule shows:
| Column | Description |
|---|---|
| Name | The rule name and a short summary of its logic. |
| Status | Whether the rule is active or paused. The history icon next to it shows when the status changed. |
| Source Event | The event that triggers the rule. |
| Output Event | The name of the event the rule creates. |
From this list you can:
- Click Edit to modify a rule. Users with view-only access see View instead.
- Click Status to switch between active and paused.
- Click Remove to delete the rule permanently.
Example use cases
These are examples of how you can use the Event Creation Rules feature. You can use different names for your output event, and different trigger and condition rules that suit your use case.
Create an event from visits to certain pages
Useful when you want a separate event for visits to one section of your site, for example your location pages.
- Trigger: PageView
- Condition:
event_urlcontains/locations/ - Output event: LocationPageView
- Field mapping:
page_name=data.page_title - Original event: keep
- Pixel: render
event_url and event_source_url are the same field. Both hold the full address of the page where the event happened, including the domain, path and query parameters, for example https://shop.com/locations/helsinki?utm_source=meta. To match a domain, use it as the value, for example event_url contains shop.com.
The slash at the end matters: /locations/ matches /locations/helsinki but not the list page /locations. Use /locations to match both.
Use event_url and data.page_title in your rules. A rule can't read the entryUrl and pageTitle fields you see in an event's Raw Data. A condition on entryUrl never matches, and a mapping to pageTitle saves the text "pageTitle" instead of the page title.
Route by order source
Split POS orders from web orders into separate events.
- Trigger:
Purchase - Condition:
webhook.source_nameequalspos - Output event:
PurchasePOS - Original event: discard
Optimize on profit, not revenue
Send margin-based values to ad platforms instead of gross revenue.
- Trigger:
Purchase - Output event:
ProfitMargin - Field mapping:
value=value - webhook.cost_of_goods - webhook.shipping_cost - Original event: keep
- Pixel: do not render
Send VAT-excluded values to ad platforms
- Trigger:
Purchase - Output event:
Purchase - Field mapping:
value=value - webhook.total_tax - Original event: discard
Remap webhook fields to standard fields
Useful when your webhook uses non-standard field names.
- Trigger:
Purchase - Output event:
Purchase - Field mappings:
value=webhook.revenue,currency=webhook.currencyCode - Original event: discard
Clean up currency text in value
Useful when your webhook sends the order value as text, such as EUR 120.50.
- Trigger:
Purchase - Output event:
Purchase - Field mapping:
value=webhook.revenue - Find and replace: find
EUR, replace with (empty) - Original event: discard
Variation: if the prefix varies (EUR, USD, €…), use the Keep only the number example instead: turn on Use pattern (.*), find [^0-9.], replace with (empty).
Track affiliate conversions separately
- Trigger:
Purchase - Condition:
source_aliasequalsaffiliate - Output event:
PurchaseAwin - Original event: keep
- Pixel: render
Identify first-time buyers
- Trigger:
Purchase - Condition: Is new customer
- Output event:
NewCustomerPurchase - Original event: keep
Variation: if your own system decides who is a new customer, use a field from your webhook instead, e.g. webhook.isFirstOrder equals true.
Keep test orders away from ad platforms
- Trigger:
Purchase - Condition:
event_source_urlcontainsstaging.myshop.com - Output event:
PurchaseTest - Original event: discard
- Block: select Block the new event in Event Mapping when you create the rule, so
PurchaseTestis stored in Tracklution but not sent to your connectors.
Variation: to match several staging hostnames in one condition, turn on Use pattern (.*) and use a pattern such as staging\.(myshop|myshop2)\.com.
How rules handle unexpected values
Event Creation Rules are built to fail safely:
| Situation | What happens |
|---|---|
| A regex pattern is invalid | The rule can't be saved. |
| Find and replace finds no match | The value passes through unchanged. |
| Find and replace fails while the rule is running | That field mapping is skipped. The field is never set to empty. |
| A pattern fails while the rule is running | The condition evaluates to false and the rule does not fire. |
| A value is longer than 2,048 bytes (2 KB) | That find and replace mapping is skipped, also in plain-text mode. A contains / does not contain condition with Use pattern (.*) on or Match case (Aa) off evaluates to false. |
Limitations and known behavior
- Event Creation Rules is in beta. Edge cases may not behave as expected. If you run into unexpected issues, open a chat to contact support.
- Rules cannot be undone. Discarded events and delivered events created by a rule are permanent.
- Block the new event in Event Mapping is only available for new event names.
- Not yet available on all servers. If you want to use this feature but can't find it, open a chat to contact support.




