Changing query source

Hi team,

I was wondering if it is possible to change the source of a query based on where the Answers iframe lives?

This could be useful for filtering analytics based on where Answers is integrated.

Thank you!

Hi Henry,

This is possible! To do this, we’ll need to add some additional configuration to the Answers.init. This is done in the additional-answers-config.js file.

  1. Go to Jambo Commands > Override Theme and select script / additional-answers-config.js. This is a file that is meant to be shadowed, so it will not impact upgrading in the future.
  2. Set the query source using the document.referrer. As an example, here I’m saying if an experience is ever iframe’d into a code sandbox, the source should be CODE_SANDBOX
  querySource: document.referrer.includes("") ? 'CODE_SANDBOX' : 'STANDARD'

To test that the source is being set correctly, visit the page where the iframe lives, conduct a query and inspect the network request – in the source parameter for the Answers API request should match the querySource you set above.

Let us know how this works for you!


Thanks for the clear response, Rose! I’ll test this out and let you know how it goes.