Repeated brand search
Searched for the same brand three times in a week and did not buy — link to the brand page.
3 search queries with the same brand within 7 days, and there is no order.
“<Brand>: all in one place” — to the brand page.
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.
<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”
Trigger · Brand searchtrg_brand → = equals → 1No 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”
Trigger · Repeated brand search{{ tag.brand_name | default: "Top brands" }}: all in one placeThe brand you were looking for — current prices and availability{{ tag.brand_url | default: "https://example.com/brands/" }}remindersJourney settings
Journeys → “New Journey” → “Settings”
Trigger · Repeated brand searchTrigger · Brand searchpurchasetrg_brand : 01 Minutes1, Period 7 daysJourney steps
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
└─ Exit2 Hours10:00–21:00. Timezone: the time zone of your audience.Tag equals value. Tag key trg_chk, Tag value 1. The Yes branch goes left, No goes right.trg_brand, Tag value 0Trigger · Repeated brand searchtrg_brand, Tag value 00.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.
What happens in different situations
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.