Widget embed code structure

Created by Certorix Online, Modified on Mon, 4 May at 9:22 PM by Certorix Online

Understanding the widget embed code

The widget embed snippet is a small piece of JavaScript that loads the Certorix widget from the CDN and initialises it with your configuration.

Example snippet

<script>
  (function(w,d,s,o,f,js,fjs){
    w['CertorixWidget']=o;w[o]=w[o]||function(){(w[o].q=w[o].q||[]).push(arguments)};
    js=d.createElement(s),fjs=d.getElementsByTagName(s)[0];
    js.async=1;js.src=f;fjs.parentNode.insertBefore(js,fjs);
  })(window,document,'script','cw','https://cdn.certorix.com/widget.js');
  cw('init', {
    treeId: 'tree_123abc',
    orgId: 'org_456def',
    trigger: 'button',
    position: 'bottom-right',
    primaryColor: '#1a3a5c',
    logoUrl: 'https://example.com/logo.png'
  });
</script>

What the code does

  1. Creates a global cw (Certorix Widget) function for configuration.
  2. Loads the widget script asynchronously from the CDN so it doesn't block page rendering.
  3. Initialises the widget with your settings: which tree to load, org ID, trigger type, appearance.
  4. When the script loads, it renders the widget (floating launcher or embedded panel).

Placement best practices

Paste the snippet just before the closing </body> tag for optimal performance. Do not paste it inside the <head> unless you defer execution.

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article