Scenario examples

Repeated brand search

Searched for the same brand three times in a week and did not buy — link to the brand page.

Trigger

3 search queries with the same brand within 7 days, and there is no order.

Push

“<Brand>: all in one place” — to the brand page.

ℹ️
Before you start, complete the base setup — it is shared by all scenarios.

What the site needs to do

The code goes on the search results page. The site detects the brand in the query using its own brand dictionary.

html
<script>
(function () {
  // Search query of this results page
  var query = String(new URLSearchParams(location.search).get('q') || '').toLowerCase();

  // Brand dictionary: spelling in lower case → name and brand page. Generate it on the server.
  var BRANDS = {
    'acme':   { name: 'Acme',   url: '/brands/acme/' },
    'акме':   { name: 'Acme',   url: '/brands/acme/' },
    'globex': { name: 'Globex', url: '/brands/globex/' }
  };

  var brand = null;
  Object.keys(BRANDS).forEach(function (slug) {
    var safe = slug.replace(/[.*+?^$(){}|[\]\\]/g, '\\$&');   // "a.c", "c++" and the like
    if (!brand && new RegExp('(^|[^a-zа-яё0-9])' + safe + '([^a-zа-яё0-9]|$)', 'i').test(query)) brand = slug;
  });
  if (!brand) return;

  var key = 'ntx_brand_search';
  var weekAgo = Date.now() - 7 * 24 * 3600 * 1000;
  var hist;
  try { hist = JSON.parse(localStorage.getItem(key) || '{}'); } catch (e) { hist = {}; }

  var name = BRANDS[brand].name;                  // spellings of one brand share a counter
  hist[name] = (hist[name] || []).filter(function (t) { return t > weekAgo; });   // 7-day window
  hist[name].push(Date.now());

  if (hist[name].length >= 3) {
    window.notirixTrigger('trg_brand', {
      brand_name: name,
      brand_url: location.origin + BRANDS[brand].url
    }, 168);                     // at most once in 7 days (for any brand)
    hist[name] = [];             // count this brand from zero after the trigger
  }
  try { localStorage.setItem(key, JSON.stringify(hist)); } catch (e) {}
})();
</script>

The dictionary. BRANDS keys are spellings in lower case. If a brand is spelled in different ways (acme / акме), add both entries with the same name and url: the counter is kept per name, so both spellings add up.

Page reloads. Reloading the same results page also counts as a search. If that matters, store the last query and skip its repeats.

For Bitrix: pass the query and the dictionary from the template with json_encode and the JSON_UNESCAPED_UNICODE | JSON_HEX_TAG flags, e.g. var BRANDS = <?= json_encode($brandsForJs, JSON_UNESCAPED_UNICODE | JSON_HEX_TAG) ?>;. The dictionary is easy to build from the “Manufacturer” property or a brands HL-block. JSON_HEX_TAG keeps a value with </script> from closing the tag.

Segment

Audience → Segments → “Create Segment”

FieldValue
Segment NameTrigger · Brand search
GroupAND
Rules+ Tag → Tag key trg_brand → = equals → 1

No other rules are needed. Right after creation “Preview Audience” shows 0 — that is expected: the flag appears once the trigger fires on the site.

Message template

Messages → Templates → “New Template”

FieldValue
Template NameTrigger · Repeated brand search
Notification Title{{ tag.brand_name | default: "Top brands" }}: all in one place
Notification BodyThe brand you were looking for — current prices and availability
Click URL{{ tag.brand_url | default: "https://example.com/brands/" }}
Image URLoptional
Tagreminders

Journey settings

Journeys → “New Journey” → “Settings”

TabSettingValue
GeneralJourney NameTrigger · Repeated brand search
Entry RulesInclude SegmentsTrigger · Brand search
Exclude Segmentsempty
Future additions onlyOn
Exit RulesOptionMeet a certain condition
Exit when custom event condition occursOn, purchase
Tag users when they exit earlytrg_brand : 0
Other checkboxesOff
Re-entryOptionYes, after a certain amount of time: 1 Minutes
ScheduleStart / EndImmediately when activated / Never ends
FrequencyRespect the app frequency capOn
This journey's limitOn: Max pushes 1, Period 7 days
When the limit is reachedSkip the push
ℹ️
The values are the same for every example scenario — only the name, the segment, the flag tag and the period of the journey limit differ. Why these values were chosen is explained in the base setup.

Journey steps

text
Entrance
└─ Wait: 2 Hours
   └─ Time Window: Mon–Sun, 10:00–21:00
      └─ Yes / No Branch: Tag equals value · trg_chk = 1
         ├─ Yes
         │  └─ Tag User: trg_brand = 0
         │     └─ Exit
         └─ No
            └─ Push Notification: “Trigger · Repeated brand search”
               └─ Tag User: trg_brand = 0
                  └─ Exit
#NodeSettings
1WaitDelay: 2 Hours
2Time WindowAllowed days: all 7 (Mon–Sun). Time range: 10:00–21:00. Timezone: the time zone of your audience.
3Yes / No BranchCondition type: Tag equals value. Tag key trg_chk, Tag value 1. The Yes branch goes left, No goes right.
4 · YesTag UserTag key trg_brand, Tag value 0
5 · YesExit—
4 · NoPush NotificationMessage Template: Trigger · Repeated brand search
5 · NoTag UserTag key trg_brand, Tag value 0
6 · NoExit—
⚠️
Both branches must be connected, otherwise the journey cannot be activated. In both branches the last step before the exit resets the flag tag to 0.

When you are done, click “Save” and then “Activate”. On activation Notirix checks the graph: every node is connected, the template is selected, the segment exists. All problems are listed in one message.

💡
Why the branch. If the visitor has already moved on to checkout, the abandoned checkout journey sends them a reminder.

What happens in different situations

SituationResult
Searched for “acme laptop”, “acme mouse” and “Acme” this weekThe third search sets the flag, the Acme push arrives 2 hours later
Searched for Acme twice and Globex onceBrands have separate counters — the trigger does not fire
Searched for Globex three times 3 days after the Acme pushThe trigger is not sent: the “once in 7 days” limit applies to the flag as a whole, for any brand
Reloaded the results pageCounts as one more search (see the note on the code)

Variations

Brand for future campaigns

Besides the flag, the site can store a fav_brand tag, e.g. acme. Campaign segments are then built from it: “interested in Acme” → an Acme promotion.

NextTesting and troubleshooting →