PricingBlog

How to Add a Custom Script Globally for All Pages?

  • chen97xiong-1283614924173479947

    Xiong

    1 year ago

    Hi everyone, I'm currently exploring the capabilities of Toddle.dev and having an issue with adding a custom script to all the pages. Right now, I need to manually import the same script in the header for each page, which is quite tedious. Is there any way to have a global-level header setting where I can add this script once and have it applied to all the pages in the project?
  • lucasg-1283616263817527399

    Lucas G

    1 year ago

    There is not
  • chen97xiong-1283616826324156426

    Xiong

    1 year ago

    @Lucas G Does this mean that if I have 20 pages, I have to do it 20 times?
  • lucasg-1283619261343993856

    Lucas G

    1 year ago

    Pretty much
  • Generally speaking, adding scripts to the header isn't recommended as they block rendering, etc
  • So an 'easier' way to go about it is to add your code via a custom action and run it onLoad
  • But ultimately, yes. You'll have to add it either way to any page you want it on
  • alext_34982-1283622060136071202

    alext

    1 year ago

    to clarify, if i wish to load scripts from google analytics, hotjar, amplitude etc, the recommended way is to add these scripts into a custom action, and run it on load for all pages?
    if so, this sounds like a 'hack-ish' way. is there a planned roadmap to support global scripts?
  • lucasg-1283623076671520831

    Lucas G

    1 year ago

    That is correct. On the plus side though, it gives a lot of flexibility as to what you report back to the platforms
  • No ETAs for global scripts
  • Currently, the main thing in the pipeline is a big update to APIs
  • chen97xiong-1283626268436201522

    Xiong

    1 year ago

    @Lucas G Thanks for the clarification 😄