Below, you’ll find a detailed guide on how to add the Google Analytics Dashboard For WP Shortcodes to your WordPress website, including their parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Google Analytics Dashboard For Wp Plugin shortcodes not to show or not to work correctly.
Before starting, here is an overview of the Google Analytics Dashboard For Wp Plugin and the shortcodes it provides:
"ExactMetrics – Google Analytics Dashboard for WordPress is a convenient tool to track and analyze your website's stats. It merges Google Analytics data into your WordPress dashboard for easy access."
- [render_badge]
- [render_shortcode]
Google Analytics Dashboard For WP [render_badge] Shortcode
The Google Analytics Dashboard for WP shortcode is a tool that renders a badge. It displays an image indicating that the website is verified by ExactMetrics. This shortcode allows customization of appearance (‘light’ or ‘dark’) and position (‘left’, ‘center’, ‘right’). It generates an HTML div containing an image sourced from the plugin’s assets.
Shortcode: [render_badge]
Parameters
Here is a list of all possible render_badge shortcode parameters and attributes:
appearance
– Specifies the badge theme, can be ‘light’ or ‘dark’position
– Sets the badge alignment, options are ‘left’, ‘center’, ‘right’
Examples and Usage
Basic example – The following shortcode displays the default ExactMetrics badge with light appearance and centered positioning.
[exactmetrics_badge /]
Advanced examples
Displaying the ExactMetrics badge with a dark appearance and left-aligned positioning. The badge will first try to load with the provided appearance and position, but if not found, it will default to light appearance and centered positioning.
[exactmetrics_badge appearance="dark" position="left" /]
Displaying the ExactMetrics badge with a light appearance and right-aligned positioning. The badge will first try to load with the provided appearance and position, but if not found, it will default to light appearance and centered positioning.
[exactmetrics_badge appearance="light" position="right" /]
PHP Function Code
In case you have difficulties debugging what causing issues with [render_badge]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode($this->shortcode_key, array($this, 'render_badge'));
Shortcode PHP function:
function render_badge($atts)
{
$atts = shortcode_atts(array(
'appearance' => 'light',
'position' => 'center'
), $atts, $this->shortcode_key);
$img_src = esc_url(plugins_url('assets/images/exactmetrics-badge-' . (in_array($atts['appearance'], array('light', 'dark'), true) ? $atts['appearance'] : 'light') . '.svg', EXACTMETRICS_PLUGIN_FILE));
return sprintf(
'<div style="text-align: %1$s;"><a href="%2$s" target="_blank" rel="nofollow"><img style="display: inline-block" alt="%3$s" title="%3$s" src="%4$s"/></a></div>',
(in_array($atts['position'], array('left', 'center', 'right'), true) ? $atts['position'] : 'center'),
$this->get_link(),
__('Verified by ExactMetrics', 'google-analytics-dashboard-for-wp'),
$img_src
);
}
Code file location:
google-analytics-dashboard-for-wp/google-analytics-dashboard-for-wp/includes/frontend/verified-badge/Controller.php
Google Analytics Dashboard For Wp [render_shortcode] Shortcode
The Google Analytics Dashboard for WP shortcode is a tool that enables the rendering of specific data. This shortcode takes in arguments ($args), checks if they are valid, and then applies them to the ‘exactmetrics_popular_posts_shortcode_output’ filter. This filter is used to modify the popular posts output. It essentially customizes the display of popular posts based on the provided arguments.
Shortcode: [render_shortcode]
Examples and Usage
Basic example – A simple shortcode to display the popular posts based on the given parameters.
[exactmetrics_popular_posts id="1" /]
PHP Function Code
In case you have difficulties debugging what causing issues with [render_shortcode]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( $this->shortcode_key, array( $this, 'render_shortcode' ) );
Shortcode PHP function:
function render_shortcode( $args ) {
if ( empty( $args ) || ! is_array( $args ) ) {
$args = array();
}
return apply_filters( 'exactmetrics_popular_posts_shortcode_output', $this->shortcode_output( $args ), $args, $this );
}
Code file location:
google-analytics-dashboard-for-wp/google-analytics-dashboard-for-wp/includes/popular-posts/class-popular-posts.php
Conclusion
Now that you’ve learned how to embed the Google Analytics Dashboard For Wp Plugin shortcodes, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.
Leave a Reply