Using variables in Script

I’ve looked all over but can’t find any information on how (if at all possible) to use a Variable value within a HTML Script?

I know we can use client.* to reference properties, but I’m unsure on if we can use a pre-defined variable in the same manner.

Thanks
Tom

Hey Tom! What do you mean by “pre-defined variable”? Can you provide an example?

If you’re referring that we call “system properties”, we need to update our docs with this information, but for now you can see this page: cloudflare-docs/properties-reference.md at ef8f289966af7afe523c816b7ab68be630b4335b · cloudflare/cloudflare-docs · GitHub

Sorry, I’m referring to Zaraz Variables as defined in this page:

Are we able to use these within a custom HTML block?

Thanks
Tom

Oh I see. Unfortunately there’s no easy way to use them now inside a Custom HTML tool, but if you’re feeling brave, try the following:

  1. Get the ID of your variable by editing it and taking it from the URL in your browser (it’s the last UUID in the URL)
  2. Use {{ variable.PUT_ID_HERE }} in your code
  3. Zaraz will replace it with your variable content
1 Like

Hi @yoav_zaraz, does this method still work? Whenever I try to input a custom variable into a script tag I get console errors, and it doesn’t execute at all. The system variables work fine though.

It should still work, yes.

1 Like