Muestra un contador de visitas de Google Analytics en tu sitio con Analyticator
Si poseen un sitio que utiliza WordPress y utilizan el servicio de Google Analytics para llevar las estadísticas de las visitas, les puede interesar Analyticator, un plugin basado en la API de Google Analytics que nos permite mostrar la cantidad de visitas de nuestro sitio.

Una vez instalado el plugin debemos configurarlo haciendo click en el enlace Google Analytics dentro del menú lateral Opciones. Allí debemos habilitar el servicio, ingresar nuestro UID de Google Analytics, el cual tiene el formato UA-11111-1, y nuestro usuario y contraseña para ingresar en Analytics. También hay varias opciones que sirven para integrar Gogole Analytics con nuestro sitio que pueden examinar ustedes mismos.
Una vez configurado el plugin tenemos dos opciones para mostrar el contador de visitas en nuestro sitio. Una es utilizando widgets, donde lo único que tenemos que hacer es agregar el widget llamado Google Analytics Stats. La otra opción más flexible, pero también algo más complicada, es agregar directamente una porción de código PHP dentro del código fuente de la plantilla y así mostrar el contador en cualquier lugar del sitio.
El código que debemos agregar en nuestra plantilla es el siguiente:
<?php global $google_analytics_stats; $google_analytics_stats->outputWidget($account, $timeFrame, $line1, $line2, $pageBg, $widgetBg, $innerBg, $font); ?>
Y esta es la explicación de la función outputWidget para que entiendan que es cada parámetro:
<?php
/**
* A custom function for outputting the widget
*
* @param account - Google Analytics Profile ID found on your profile settings page.
* (For more info check out http://plugins.spiralwebconsulting.com/forums/viewtopic.php?f=5&t=128)
* @param timeFrame - The number of previous day's traffic stats used. (Example: 1 = Yesterday, 2 = Last Two Days, etc...)
* @param line1 - The upper line of text displayed by the widget
* @param line2 - The lower line of text displayed by the widget
* @param pageBg - The background color of the entire page in hexadecimal form without the #
* @param widgetBg - The background color of the widget in hexadecimal form without the #
* @param innerBg - The background color of the inner part of the widget in hexadecimal form without the #
* @param font - The font color in hexadecimal form without the #
**/
function outputWidget($account, $timeFrame, $line1, $line2, $pageBg, $widgetBg, $innerBg, $font)
{
$this->initiateBackground($pageBg, $font);
$this->beginWidget($font, $widgetBg);
$this->widgetInfo($this->getUniqueVisitors('ga:' . $account, $timeFrame), $line1, $line2, $innerBg, $font);
$this->endWidget();
}
?>
Gracias a este plugin podemos mostrar de manera sencilla a nuestros visitantes y posibles anunciantes la cantidad de visitas que tiene nuestro sitio.


