URL parameters and embedded charts

I’ve seen that you can pass URL parameters to a notebook and use those to filter data. But how would something like that work for an embedded chart?

So let’s say you want to display a personalized chart when someone navigates to yourdomain.com/charts?username=abc? Would you need to pass the URL parameter to an embedded viewof element?

Any pointers in the right direction are appreciated!

It works in the exact same way. That is, if you navigate to


then username should have the value abc within your Observable authored Javascript.

@mcmcclur, sorry for not being clear enough in my initial post. How do you pass that parameter to Observable using the embed code? I’m probably missing something obvious.

Okay, I reread your reply and figured that I was making things too complicated. The URL parameters are automatically passed on to the Observable javascript. Well, that makes life much easier!

Looks like you are all set, but for others, here is an example notebook where I am embedding a chart with an iframe with different URL parameters passed to the embedded chart.


Thanks for pitching in @Cobus. The iframe example could definitely be relevant to others. I’m on the JS embed method train right now. In general, this might be a useful addition to the Observable documentation on embedding charts.

1 Like

Indeed. Making a note of that.