Hi, I'm currently facing an issue with `client.set` not being executed when called from a custom ma

Hi, I'm currently facing an issue with client.set not being executed when called from a custom managed component in a custom action. It works, if I call it in an event handler for the default "Pageview" action, but not in any event handler for a custom action. In my example below, the value for the event "detailedPageview" is always null, for the "pageview" event the value is set after first execution.
export default async function (manager: Manager, _settings: ComponentSettings) {
manager.addEventListener('detailedPageview', async event => {
const { client } = event
let getResponse = client.get('key2')
console.log('getResponse', getResponse)
// ^ this always logs null
client.set('key2', 'value2')
getResponse = client.get('key2')
console.log('getResponse', getResponse)
})

manager.addEventListener('pageview', async event => {
const { client } = event
let getResponse = client.get('key')
console.log('getResponse', getResponse)
// ^ this one logs the value, once it has been set
client.set('key', 'value')
getResponse = client.get('key')
console.log('getResponse', getResponse)
})
}
export default async function (manager: Manager, _settings: ComponentSettings) {
manager.addEventListener('detailedPageview', async event => {
const { client } = event
let getResponse = client.get('key2')
console.log('getResponse', getResponse)
// ^ this always logs null
client.set('key2', 'value2')
getResponse = client.get('key2')
console.log('getResponse', getResponse)
})

manager.addEventListener('pageview', async event => {
const { client } = event
let getResponse = client.get('key')
console.log('getResponse', getResponse)
// ^ this one logs the value, once it has been set
client.set('key', 'value')
getResponse = client.get('key')
console.log('getResponse', getResponse)
})
}
16 Replies
_fe_he
_fe_he4w ago
I'm also encountering issues with custom Actions. My custom action is called according to the zaraz debugger console (screenshot 1) The event which is fired is called "purchase" (screenshot 2) But my managed component is not running the code even though the eventListener is correctly implemented: manager.addEventListener('purchase', async event => { console.log('purchase', event) await sendEventPurchase(event, settings) }) The weird thing is, that occasionally the event is correctly executed (I'd say 10% of the time). Any suggestions?
No description
No description
Unknown User
Unknown User3w ago
Message Not Public
Sign In & Join Server To View
_fe_he
_fe_he3w ago
If you mean the "Custom HTML" Tool, its executed in the browser (client), just like it would in a traditional tag manager
Unknown User
Unknown User3w ago
Message Not Public
Sign In & Join Server To View
Beto Garcia
Beto Garcia3w ago
Input form BUG in dashboard: When you select the value inside the input and paste some value, the old value remains before and after the pasted value. The natural behavior is to replace the old selected value with the new one. This is causing problems for clients.
Beto Garcia
Beto Garcia3w ago
The Include Event Properties turning OFF BUG remains:
m.muiznieks
m.muiznieks3w ago
For the last one I usually turn it off and on, then it saves.
mauz
mauz3w ago
Hello I'm not able to make Google Ads work using Zaraz for my website. I've set up Google Ads third party tool and put the conversion ID coming after AW-. But when I test the connect on Google tag it says it's not detected on my website also Ive setup a custom action and set the Conversion label and added a firing trigger when I clic on a button nothing is detected by google ads
mauz
mauz3w ago
also I can see in the zaraz debugger that trigger are fired and action are called and sent to google ads but the converstion counter in gad stays at 0
m.muiznieks
m.muiznieks3w ago
Google tag will not detect that, as no google script is injected. The event processing happens on the "server-side", which sends a http request to Google ads/analytics, etc
mauz
mauz3w ago
@m.muiznieks thank you for you quick answer I understand I would expect the goal counter to go up in google ads but it stays 0 also in zaraz debugger Idk why the trigger/action are sent twice when I clic on my buttonim using Xpath on a very specific xpath
m.muiznieks
m.muiznieks3w ago
I am not using the Google ads integration for myself, so I cant comment on that now. I suggest you to try this from the google analytics side. 1. In the zaraz integration check the events you value as "conversion", 2. connect your google ads account to google analytics account.
m.muiznieks
m.muiznieks3w ago
Most likely this is caused because the Zaraz triggers twice - once on the "general event" and second - on the "custom event". I solved similar case by duplicating the events as custom (2) and switching the default ones off(1).
No description
Rafael Machado
The counter won't go up if you are not testing with a valid gclid.
m.muiznieks
m.muiznieks3w ago
Hi, all. I'm playing with the context workers and I have a few questions:
export default {
async fetch(request, env ): Promise<Response> {
const { system, client, headers } = await request.json() as Response;

return new Response("test", { status: 200 });
},
} satisfies ExportedHandler<Env>;
export default {
async fetch(request, env ): Promise<Response> {
const { system, client, headers } = await request.json() as Response;

return new Response("test", { status: 200 });
},
} satisfies ExportedHandler<Env>;
1. what is the correct type for the request, so the Typescript does not complain about system and client? The documentation isnt showing the TS version and everything that I tried - fails. Or should I write the types manually (I will do that for now, of course). 2. Are there any ways how to get the headers values from the incoming request? Or is there a way how to get them in the Zaraz context? Everything I try either returns null values. I am talking about this part of the headers: https://developers.cloudflare.com/fundamentals/reference/http-headers/
Cloudflare Docs
Cloudflare HTTP headers · Cloudflare Fundamentals docs
Cloudflare passes all HTTP request headers to your origin web server and adds additional headers as specified below.

Did you find this page helpful?