How to set up AskGov widget on my website?
Step 1: Whitelist the AskGov domain
Ensure you have the following in your Content Security Policy (CSP) so the widget can load on your site.
script-src:
https://*.ask.gov.sg
connect-src:
https://ask.gov.sg
https://*.ask.gov.sg
img-src:
https://*.ask.gov.sg
Step 2: Get your Agency Code
Your Agency Code is the unique identifier for your AskGov page.
It is the part of your AskGov URL after https://ask.gov.sg/.
For example, for https://ask.gov.sg/ogp, the agency code is ogp.
You will need this code to embed the widget correctly.
Step 3: Embed the widget HTML
If your agency website is on Isomer:
Isomer Next: Reach out to Isomer Ops team and share your Agency Code and the site you want it to be embedded on with them.
Isomer Classic: In your Isomer Pages repository, place the script in:
<Your Repository>/_includes/chatbot-scripts.html
If your agency website is not on Isomer:
Add the following script tag into your website's tag
Replace with the Agency Code you have retrieved earlier (refer to example below)
If you are placing the script in the <head>, use the defer attribute.
Production widget code snippet:
<div id="askgov-widget" data-agency="Your Agency Code"></div> <script src="https://script.ask.gov.sg/widget.js"></script>
The widget will show content pulled from your AskGov production site. Suitable for actual live implementation of widget.
Staging widget code snippet:
<div id="askgov-widget" data-agency="Your Agency Code"></div> <script src="https://script-staging.ask.gov.sg/widget.js"></script>
The widget will show content pulled from your AskGov staging site. Suitable for testing of widget implementation or if you don't have a production AskGov site.
You should only choose one code snippet which is relevant for your use case.
Example of code snippet with "Your Agency Code" replaced with "ogp":
<div id="askgov-widget" data-agency="ogp"></div> <script src="https://script-staging.ask.gov.sg/widget.js"></script>
Step 4: Pin quick links in the widget
To feature quick links in your widget, email us at enquiries@ask.gov.sg and let us know the 3 articles you want to display.
Notes:
The AskGov widget uses Microsoft Clarity to provide better analytics on user behaviour.
Adding clarity.ms to your CSP is optional, and the widget will continue to function normally even if it is not included.Please allow 5-7 business days to process your request.