Unable to get the current experiment
I am trying to set up an experiment on an iFrame. The src of the iFrame is with some dynamic parameters from database. I have already tried to make a simple "Hello World" experiment on an iframe with simple URL and it went successfully. I can see the experiment in experiments object but I can not find any experiments in state object.
Question: how can I set up experiment with a dynamic URL?
I presume "experiments object" means the DOM object named "optimizely", but what do you mean by "state object"?
Is the Optimizely snippet on the main page or is it on the page that is inside the iFrame?
Is the page inside the iFrame on the same domain as the main page or is it a different domain?
From the main page, you can change the "src" attribute of the iFrame, but accessing elements inside the iFrame requires that iFrame be on the same domain (cross-site scripting is prevented in every modern browser).
If the cross-site scenario, this means you will not be able to alter or even measure interactions/engagement with the content of the iFrame.
If it is the same domain, you should be able to access the content to alter it and/or measure engagement just fine.
Your question: "how can I set up an experiment with a dynamic URL"
Do you want to set up an experiment that runs on many different URLs or are you wanting to alter the URL of the current page?
If the former, you handle this through URL targeting. If you share a few examples of what patterns to look for, we can help you set up URL targeting that matches the criteria you describe.
If the latter, it sounds like you will want to do a "redirect" test (where you alter the URL of the current page, causing a different page to load in the browser). You can read about this here: https://help.optimizely.com/hc/en-us/articles/2000
Any additional details you can give will be helpful in providing better answers.