首页 > 解决方案 > 在 iFrame 中嵌入带参数的 URL(Google DataStudio 报告)

问题描述

我正在尝试将 Google Data Studio 报告 URL 作为 iframe 嵌入 Wordpress 中。

使用 Data Studio 提供的报告 URL(嵌入报告)时可以正常工作: <iframe width="600" height="450" src="https://datastudio.google.com/reporting/1FcmV-tCfAEu-WdUk73QWPjRoiSEPuHIf/page/J09y" frameborder="0" style="border:0" allowfullscreen></iframe>

当 URL 带有用于行级过滤数据的参数时,它不起作用: <iframe width="600" height="450" src="https://datastudio.google.com/reporting/1FcmV-tCfAEu-WdUk73QWPjRoiSEPuHIf/page/J09y?config=%7B%22walcid%22%3A%7B%22walcid%22%3A%22abcd1234%22%7D%7D" frameborder="0" style="border:0" allowfullscreen></iframe>

但是,当您将其直接粘贴到浏览器中时,该 URL 确实有效。 https://datastudio.google.com/reporting/1FcmV-tCfAEu-WdUk73QWPjRoiSEPuHIf/page/J09y?config=%7B%22walcid%22%3A%7B%22walcid%22%3A%22abcd1234%22%7D%7D

当数据洞察报告 URL 包含参数时,Google 会设法防止跨域加载/嵌入。你能想出一种在我控制的域中加载参数化 URL 的方法吗?

我试过<iframe> <embed> <object>了,但似乎没有任何效果。

任何指针表示赞赏!

标签: htmliframegoogle-data-studio

解决方案


你好我知道这可能是一个旧线程,但我想帮助任何可能面临这个问题的人。

params(查询参数的键)替换为config. 如果您使用的是嵌入。

原始嵌入 iframe 应如下所示

<iframe width="600" height="450" 
src="https://datastudio.google.com/embed/reporting/1FcmV-tCfAEu-WdUk73QWPjRoiSEPuHIf/page/J09y" frameborder="0" style="border:0" allowfullscreen>
</iframe>

如果你想使用参数,你可以让它成为

<iframe width="600" height="450" 
src="https://datastudio.google.com/embed/reporting/1FcmV-tCfAEu-WdUk73QWPjRoiSEPuHIf/page/J09y?config=%7B%22walcid%22%3A%7B%22walcid%22%3A%22abcd1234%22%7D%7D" frameborder="0" style="border:0" allowfullscreen>
</iframe>

我认为您错过了URL 中的/embed/after datastudio.google.com

我在https://developers.google.com/datastudio/solution/viewers-cred-with-3p-credentials中找到了这个

数据工作室的文档仍然需要改进。

希望这可以帮到你。


推荐阅读