The Instructure Community will enter a read-only state on November 22, 2025 as we prepare to migrate to our new Community platform in early December.
Read our blog post for more info about this change.
Found this content helpful? Log in or sign up to leave a like!
I'm a new Canvas admin and am trying to figure if I can annotate iFrame URLs with user information. I have a survey that I'd like to embed in a Canvas page; the first question is hidden and ideally would populate with the student's Canvas user ID. Theoretically, the HTML content of the page would look like the following, but the portion in pink would be dynamic to the viewing user's ID. Is this something that (1) is doable in Canvas and (2) someone with limited API/LTI knowledge would be able to easily implement? Thanks!
<iframe src="https://survey.clicktools.com/app/survey/go.jsp?iv=3vo8w3wtc10a5&q1=user_id" width="100%" height="600"></iframe></p>
Solved! Go to Solution.
Hi Shanna --
You could accomplish this using either some custom Javascript or by building a simple LTI tool. For the Javascript approach, you could take advantage of the fact that every Canvas page has some special Javascript variables available , including one that contains the user ID of the currently logged-in user:
ENV['current_user_id']
(You can see all of these special environment variables by opening your browser's developer tools console and typing 'ENV') Your custom Javascript could look for an iframe with your clicktools URL in the src, and append the value of the ENV['current_user_id'] variable. The pros of this approach are that it'd be fairly simple code to write, and it wouldn't require you to run any server-side software. The cons are that the Javascript code would probably need to run on every page, and that using Javascript to manipulate a page's content like this can be brittle (it can stop working if the page's markup changes in unexpected ways).
You could write an LTI tool that would accomplish something similar. When a user clicks on a link to an LTI tool that's installed in an LMS, the LMS generates an HTTP POST request to the tool. This is called the LTI launch request, and it passes a bunch of different parameters from the LMS to the tool, including the user ID. You could write a very simple LTI tool that receives these parameters and then redirects the user to the clicktools URL with the user ID appended, and the survey would get loaded in an iframe inside of Canvas. The pros of this approach are that you'd be using a stable, standard protocol to receive the user ID from Canvas. The cons are that the code would be more complicated to write, and you'd need to have a server on which to run it (and all of the complexity that comes along with that).
Good luck!
--Colin
Hi, @sharper Welcome to the Canvas Community! I've shared your question with the https://community.canvaslms.com/groups/designers?sr=search&searchId=4ee729d6-7236-4e28-81b1-41cc0414... group to see if anyone there has devised an innovative way to accomplish this.
Thank you, stefaniesanders!
Hi Shanna --
You could accomplish this using either some custom Javascript or by building a simple LTI tool. For the Javascript approach, you could take advantage of the fact that every Canvas page has some special Javascript variables available , including one that contains the user ID of the currently logged-in user:
ENV['current_user_id']
(You can see all of these special environment variables by opening your browser's developer tools console and typing 'ENV') Your custom Javascript could look for an iframe with your clicktools URL in the src, and append the value of the ENV['current_user_id'] variable. The pros of this approach are that it'd be fairly simple code to write, and it wouldn't require you to run any server-side software. The cons are that the Javascript code would probably need to run on every page, and that using Javascript to manipulate a page's content like this can be brittle (it can stop working if the page's markup changes in unexpected ways).
You could write an LTI tool that would accomplish something similar. When a user clicks on a link to an LTI tool that's installed in an LMS, the LMS generates an HTTP POST request to the tool. This is called the LTI launch request, and it passes a bunch of different parameters from the LMS to the tool, including the user ID. You could write a very simple LTI tool that receives these parameters and then redirects the user to the clicktools URL with the user ID appended, and the survey would get loaded in an iframe inside of Canvas. The pros of this approach are that you'd be using a stable, standard protocol to receive the user ID from Canvas. The cons are that the code would be more complicated to write, and you'd need to have a server on which to run it (and all of the complexity that comes along with that).
Good luck!
--Colin
Wow - I never knew about ENV['current_user_id'] @colinmurtaugh - thanks for sharing!
Hi @Colin Murtaugh, I think maybe you can answer my question
Thanks for yours collaborations
I'm also checking similar question.
Now i'm successfully integrated LTI ,it's working fine
but i'm trying to pass values through Iframe without LTI. Is there any possibility to pass ENV varibale?
<iframe src="https://dummysite.com?userid=ENV['current_user_id']" width="100%" height="600"></iframe>
I was tried above one, that is not working. please give me some suggestion
Thanks
I don't know if this helps, but you can access the user's id by grabbing the ENV.current_user.id Javascript object. How you can dynamically build a url for an iframe, that's a little more difficult, with Canvas scrubbing Javascript created within the RCE. LTI would be the best approach, but maybe this helps.
Hi there, have you figured this out? I'm running into the same problem and just wonder if you can share your solution.
@cla_user You can use the Redirect Plus tool that allows you to include data from Canvas in the URL of page to load in the iframe.
Does this work without LTI?
No, the Redirect Plus solution is an LTI, but is can be easily configured to appear in just a single course.
sorry I have limited experience with web dev. So basically I'll give the user a link and when they link on the link, instead of being redirected to an external link, the user will see the imbedded page that matches with their id?
Community helpTo interact with Panda Bot, our automated chatbot, you need to sign up or log in:
Sign inTo interact with Panda Bot, our automated chatbot, you need to sign up or log in:
Sign in