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 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.
script
/ additional-answers-config.js
. This is a file that is meant to be shadowed, so it will not impact upgrading in the future.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("csb.app") ? '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!
Rose
Thanks for the clear response, Rose! I’ll test this out and let you know how it goes.