Embed an External Analytics Dashboard
Adds a dashboard widget that shows a shared dashboard from another service, such as a public Plausible, Looker Studio or uptime status page, so clients see their numbers without another login.
Opens WPIDE on
Code
// Public embed or share link (https only).
$wpide_embed_url = 'https://plausible.io/share/example.com?auth=YOUR_SHARED_LINK_KEY&embed=true&theme=light';
$wpide_embed_title = 'Site analytics';
$wpide_embed_height = 600;
add_action( 'wp_dashboard_setup', function () use ( $wpide_embed_url, $wpide_embed_title, $wpide_embed_height ) {
if ( ! current_user_can( 'edit_posts' ) || 0 !== strpos( $wpide_embed_url, 'https://' ) ) {
return;
}
wp_add_dashboard_widget( 'wpide_external_embed', $wpide_embed_title, function () use ( $wpide_embed_url, $wpide_embed_title, $wpide_embed_height ) {
printf(
'<iframe src="%s" title="%s" loading="lazy" referrerpolicy="no-referrer" style="width:100%%;height:%dpx;border:0"></iframe><p><a href="%s" target="_blank" rel="noopener">Open in a new tab</a></p>',
esc_url( $wpide_embed_url ),
esc_attr( $wpide_embed_title ),
(int) $wpide_embed_height,
esc_url( $wpide_embed_url )
);
} );
} );
Notes
Paste the service's public share or embed link into $wpide_embed_url; the service must allow being shown in a frame.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.