Embedding a Google Analytics panel in WordPress

[members_logged_in]
Embedding a Google Analytics panel in WordPress

Google Analytics offers the ability for users to create custom panels that can then be fed out to other locations. In this webinar, we will look at how to create custom panels and then how to import those custom panels into the WordPress dashboard for clients.

Save the Webinar 0

Webinar Originally Broadcast: July 27, 2024

Video Download: HD Download | Mobile Download

Additional Notes:

Code samples from the webinar

add_action('wp_dashboard_setup', 'custom_client_dash');
function custom_client_dash(){
	wp_add_dashboard_widget('clientdashupdate', 'Special Stats for Client', 'clientdashfunc');
}

function clientdashfunc(){
	//$country = wp_remote_get('https://demo.piwik.org/index.php?module=API&method=UserCountry.getCountry&format=JSON&idSite=3&period=day&date=yesterday&expanded=1&token_auth=anonymous&filter_limit=5');
	//$country = wp_remote_get('https://demo.piwik.org/index.php?module=API&method=UserCountry.getCountry&format=JSON&idSite=3&period=month&date=2016-12-31&expanded=1&filter_limit=10');
	$country = wp_remote_get('https://demo.piwik.org/index.php?module=API&method=Referrers.getKeywords&format=JSON&idSite=3&period=year&date=2017-09-12&expanded=1');
	$country_extract = wp_remote_retrieve_body($country);
	$countrynow = json_decode($country_extract, true);
	echo 'Stats';
	foreach($countrynow as $stat){
		if ($stat["label"] == 'Keyword not defined'){
		echo 'Direct entry from browser -- '.$stat["nb_visits"].' visitors.
'; } else { echo $stat["label"]. ' -- ' .$stat["nb_visits"].' visitors.
'; } } echo '
'.print_r($countrynow, true).'

';
}

[/members_logged_in] [members_not_logged_in]

You need to be logged into your membership account to have access to the webinar replays.

[/members_not_logged_in]
Back to Top