Firing multiple times
I'm searching the forum for a similar issue I'm facing now, but can't find any.
The issue I'm facing is that a Custom Html tool fires 3 times: 1 when the the Firing Trigger meet the conditions (That the normal behaviuor) and another tiem when other Custom Html tools fires and one more time with a visibilityChange fires.
The code snippets that are injected by zaraz are:
For the 1st time
(function(w,d){{const d = document.createElement('div');d.innerHTML = ``;document.body.appendChild(d);};{
console.log('Event Busqueda fired');
// zaraz.track('Busqueda',{event_url: window.location.href.split('?')[0],search_term:"educacion" });
}})(window,document)
5 Replies
Post screenshots of your tool, action, and trigger configs
These are the trigger and tool configs.
The custom html fires 3 times if the zaraz.track is commented, if zaraz.track is uncommented it loops in an infinite way.
Site is a wordpress and I'm trying to track the search


So, when the ULRcontains
?s=
you're firing a custom HTML MC that then calls Zaraz track? What's your use case for calling Zaraz track within Zaraz?Well, another option is to have some javascript running in the browser cheching whe the url changes, and if this change match the ?s= then put the zaraz.track in the DOM.
For me is more simple let zaraz do this job with the Custom HTML tool
Anyway, I solved this in another way. Now the Trigger that fires the Custom HTML is a Form Submision, because the wordpress search is a form. Ths way the Custom HTML fires only 1 time.
But I'm interested in know why doing things like I've explained, the custom HTML fires 3 times, And if you uncomment the zaraz.track, then it fires infinite times
You probably don't need to track that manually. Without seeing your full setup, it is hard to say for sure, if you're looking to track when someone searches using WordPress, the form submission is a good option, but if you want to do a URL based trigger you'd just want to use the Pageview track call and only fire when the
s
param is present. You don't have to worry about passing the URL or manually calling zaraz.track.