Salut,
Est-ce possible pour toi de dévoiler les étapes que tu as pris pour reconstruire http://www.fg-webdesign.de/google-analytics/analytics/cron? J'ai réussi à faire afficher les stats de mon compte Analytics avec l'exemple qu'il donne mais je ne suis pas assez expérimenté pour construire le tableau que tu as sur http://jeanviet.info/cake/index.php/analytics/stats.
Merci à l'avance.
Salut,
J'en étais sur que ça intéresserai qqn... impressionnant ce script:
http://jeanviet.info/cake/index.php/analytics/stats
Je vais t'épargner la journée de labeur qu'il ma fallu pour decrypter toute la doc de cake php.
c'est vrai que le gars de fg-webdesign aurait pu nous faciliter la tâche (ah ces allemands !)...
Je reviens vers toi au fur et à mesure !!!
En te décrivant comment j'ai procédé pour afficher mes stats... je te préviens c'est pas de la tarte !!!
Pour ceux qui ne comprennent rien à ce post...
Sachez que l'on fait référence ici au script php développé par ThinkingPHP qui est le seul à permettre d'interagir avec google analytics
et donc d'afficher vos stats google analytics sur votre site !!!
Pour aller plus vite, je te propose de télécharger ce fichier zip.
cake php et google analytics api configuré par jeanviet
Ca ira beaucoup plus vite après.
Je te propose d'afficher ça sur ton site:
stats google analytics fourni par jeanviet
Si tu veux personnaliser la page à tes couleurs... je t'expliquerai plus tard (si tu es pressé, ça se joue au niveau de /app/views/layouts/default.thtml)
1/ Dans le fichier Zip
Dézippe tout dans un répertoire.
J'ai fait tout ce qu'il faut pour afficher tes stats quotidiennes.
Il y a juste à paramétrer ce fichier
/app/controllers/analytics_controller.php
dans ce fichier, renseigne ces deux variables:
$email = 'pseudo@gmail.com';
$pass = 'password gmail';
avec ton compte gmail et ton mot de passe.
Dans la fonction stats() - appelé testReports chez thinkingphp
si tu as plusieurs comptes analytics, et que tu veux consulter le compte 2 (au lieu du 1)
remplace ça (toujours dans analytics_controller.php):
$firstProfile = $profiles[0]['id'];
par ça:
$firstProfile = $profiles[1]['id'];
2/ Copie tout avec ton ftp à la racine de ton site dans un répertoire stats
3/ appelle cette url:
tondomaine.com/stats/index.php/analytics/stats
chez moi c'est ça:
http://jeanviet.info/stats/index.php/analytics/stats
4/ je t'ai épargné toutes les nombreuses manips que j'ai dû faire pour avoir qqch de stable.
pour info:
la mise en forme des stats se joue ici: /app/views/analytics/stats.thtml
la mise en forme de ta page ici: /app/views/layouts/default.thtml
5/ Alors qu'est-ce que ça donne chez toi ?
Cette astuce n'a pas l'air d'intéresser le public francophone
Il y a Svetlana de finlande qui m'a envoyé ça par email:
Hello, Jean!
May be you can help me with Google Analytics API statistic.
Unfortunately , I don't speak French, and I didn't found answer blank in
your forum...
I used your analytics.zip pakkage, and at this moment I have many
mistakes in stats.thtml file like Notice: Undefined index.
It is possible to check it here:
http://******.fi/cake/
Do you have any idea, that is happened there? I'll be grateful for any
answer from you.
Thank you a lot for you work!
Regards,
Svetlana.
--
Non-french people, i'm going to help you
To post in the forum you must register you, it's here:
Register to the forum
3 informations to give: email, nickname, password (x2)
After you can post !!
For english people, please write in blue...
I made a new view for US-English Users
http://jeanviet.info/webanalytics/index.php/analytics/stats
Now the new zip file which goes well:
cake php and google analytics api created by jeanviet
Everything has been written in us-english language.
If you want to personnalize your page, its here: /app/views/layouts/default.thtm
Unzip my zip file
1/ Go there, and edit the php file:
/app/controllers/analytics_controller.php
Change this
$email = 'yournickname@gmail.com';
$pass = 'yourpassword';
with your gmail webmail adress and your password
in the function stats() - called testReports at thinkingphp
if you have several analytics accounts, and you want to see the account 2 (instead of 1)
change this (still in analytics_controller.php):
$firstProfile = $profiles[0]['id'];
by this:
$firstProfile = $profiles[1]['id'];
2/ upload everything with your ftp client at the root of your site in a folder called webanalytics
3/ call this url:
yourdomain.com/webanalytics/index.php/analytics/stats
for me it's this:
http://jeanviet.info/webanalytics/index.php/analytics/stats
4/ hope it will help you.
you can edit view of stats here: /app/views/analytics/stats.thtml
you can edit view of page here: /app/views/layouts/default.thtml
Bonjour,
J'ai moi aussi essayé votre outil et malheureusement j'obtiens des ereurs:
Warning: curl_setopt() [function.curl-setopt]: CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set in
Warning: curl_setopt() [function.curl-setopt]: CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set in on line 120
Notice: Undefined offset: 0 in on line 75
Warning: curl_setopt() [function.curl-setopt]: CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set in on line 120
Savez vos d'où cela peut provenir et si il y a un moyen de les résoudre?
Au plaisir de votre prochain contact
Merci pour ton aide.
J'ai enlevé la protection et maintenant les statistiques s'affichent bien il subsiste pourtant 2 erreurs php:
Warning: curl_setopt() [function.curl-setopt]: CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set on line 120
Warning: curl_setopt() [function.curl-setopt]: CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set on line 120
D'où cela pourrait-il encore provenir?
Ya t'il une maniere de placer ce script dans un repertoire protégé?
Et bien en fait il n'est pas accessible au grand public, je l'ai mis dans mon espace gestion afin d'avoir une vue globale de la situation du site... Mais en tout cas je vous assure que ca fonctionne bien. Au fait tu utilises le meme script pour obtenir le top5 Reffer?
Oui c'est le même script on devrait pourvoir sortir tout ce google analytics sait sortir.
Là en fait, la fonction fait appel à ce qu'on a dans présentation générale des dirigeants, si tu veux rajouter les 5 1ères visites par source en vision hebdo, fait ça dans stats.thmtl ou dans default.thtml:
ProvencanceVisites
Hello! Thank you very much for offering to help english-language speakers. I have cake set up on my macbook pro. i was able to get the formula from ThinkingPHP working, but I feel totally ignorant about creating a view for my data. So I thought I would take a look at your work; your stats site is extemely nice. I installed your files in my webroot and I can see the data; unfortunately the view is still not working. every cell the report has this text:
Notice: Undefined variable: reports in //cake/app/views/analytics/stats.thtml on line 8
Where is $reports defined and why can's stats.thtml pick it up? what should I check?
Thanks!
Michael
Hi Michael,
We're talknig about the mix of files i made here:
http://jeanviet.free.fr/google/webanalytics.zip
reports is defined in stats() function which you can find here:
/app/controllers/analytics_controller.php
After putting the content of my zip file here on you website:
http://yoursite.com/webanalytics/
It's imprtant to call this url:
http://yoursite.com/webanalytics/index.php/analytics/stats
Have you done all i said here:
http://forum.jeanviet.info/comments.php?DiscussionID=66&page=1#Comment_518
Where can we find your stats views ?
can you send us your url ?
Hope i'll solve your problems
Tell me if what i said solved something
I tried forming the url as you suggest, with index.php in there, but this always results in:
You are seeing this error because the action index.php is not defined in controller AnalyticsController
If you want to customize this error message, create app/views/errors/missing_action.thtml.
I am only using localhost. I will recreate on a server that can be reached. It would probably be good to try this over again anyway.
Thanks!
Are you using my files ?
http://jeanviet...e/webanalytics.zip
Check in:
/app/controllers/analytics_controller.php
Try to find the function stats at the end of the php file.
If you're still using the file of thinking php, it won't work.
Maybe test on a website, I haven't test local
Salut Jeanviet,
Pour moi ça fonctionne à merveille (tant que c'est pas chez free ).
Je ne connaissais pas cakePHP, c'est assez puissant comme système!
J'ai fais quelque modifications, j'ai généré des graphiques avec artichow, j'ai touché un peu à cake pour qu'il me génère une url ce terminant par .png pour pouvoir poster les graphs sur des forums.
Et comme tu demandais des liens pour encourager ceux qui galairerai, en voila un: www.ogsteam.fr/~ben12/cake/index.php/analytics/stats
Bonne stats,
--ben.12
I am making progress! I've made a fresh install of your files on a different server. Now the stats page loads perfectly, except- there is no data. I made sure to put my e-mail address and password in analytics_controller.php. And no errors of any kind were generated. Any ideas?
Thanks!
Michael
HI michael_s,
no stats... well, have you got several sites on your google nalytics accounts ?
Maybe, one is making no traffic.
If you change theses values:
change this (still in analytics_controller.php):
$firstProfile = $profiles[0]['id'];
by this:
$firstProfile = $profiles[1]['id'];
Maybe it will work.
How many sites have you got on your GA account ?
I found my error- due to all of the copying and pasting I was using the wrong analytics_controller.php. Now that is fixed, I am seeing my stats! I would like to progress further and look at different information- do you have any advice for where to change things a bit?
Thanks again!
Alors, bon ça vas pas être simple car il faut commencer par corriger un ou deux bug dans artichow.
D'abord, télécharger la dernière version d'artichow.
Une fois cela fait, il faut éditer le fichier "Artichow.cfg.php" et changer la valeur de la définition du préfixe des classes car il y a un confit avec cakephp, j'ai mis "Arti":
/* * Prefix for class names * No prefix by default */define('ARTICHOW_PREFIX', 'Arti');
Ensuite, et malheureusement, les programmeurs d'artichow après les changement de la dernière version on oublié de tester ça, et ça ne fonctionne pas, il faut éditer /php4/inc/drivers/gd.class.php et/ou /php5/inc/drivers/gd.class.php et remplacer les 2 ou 3 "Driver()" par "awDriver()".
OK, maintenant ça devrait fonctionner à moins que votre serveur ne connaisse pas l'antialiasing, dans ce cas commentez la ligne dans la fonction setAntiAliasing toujours dans le fichier gd.class.php:
awImage::drawErrorFile('missing-anti-aliasing');
A part ça, Artichow fonctionne très bien .
Bon maintenant on peut commencer:
1. Copier le dossier que vous nommé "artichow" contenant la librairie dans la racine de cake là ou il y a les dossier app et cake.
2. Dans /app/controllers/analytics_controller.php, ajouté la methode:
function visits() { $this->layout = "ajax"; $profiles = $this->GoogleAnalytics->listProfiles($this->loginCookie); $firstProfile = $profiles[0]['id']; $this->set('report'); $report = $this->GoogleAnalytics->getReport($this->loginCookie, $firstProfile, GA_REPORT_EXECUTIVE_OVERVIEW, '-7 days', 'yesterday', 10, GA_FORMAT_CUSTOM_ARRAY); $this->set('reports', $report); }
Remarquez le "$this->layout = "ajax";" pour ne pas avoir d'html dans l'image.
3. Créez le fichier /app/views/analytics/visits.thtml et écrivez le code suivant:
J'explique pas comment ça fonctionne, il faut aller voir la docu d'Artichow et les nombreux exemples. Remarquez juste que je récupère les infos passez par cakaphp dans les premières lignes. J'ai fait un utf8_encode car mon serveur n'est pas en utf-8.
Bon ben voila vous devriez avoir un joli graph.
Pour de ce qui est de l'extension '.png', dans /cake/dispatcher.php :
Ligne 168:
remplacer:
if((in_array($params['action'], $classMethods) || in_array(strtolower($params['action']), $classMethods)) && strpos($params['action'], '_', 0) === 0) { $privateAction = true; } if(!in_array($params['action'], $classMethods) && !in_array(strtolower($params['action']), $classMethods)) { $missingAction = true; } if (in_array(strtolower($params['action']), array('tostring', 'requestaction', 'log',
par:
if((in_array(str_replace('.', '', $params['action']), $classMethods) || in_array(strtolower(str_replace('.', '', $params['action'])), $classMethods)) && strpos(str_replace('.', '', $params['action']), '_', 0) === 0) { $privateAction = true; } if(!in_array(str_replace('.', '', $params['action']), $classMethods) && !in_array(strtolower(str_replace('.', '', $params['action'])), $classMethods)) { $missingAction = true; } if (in_array(strtolower(str_replace('.', '', $params['action'])), array('tostring', 'requestaction', 'log',
et ligne 268:
$output = call_user_func_array(array(&$controller, $params['action']), empty($params['pass'])? null: $params['pass']);
par:
$output = call_user_func_array(array(&$controller, str_replace('.', '', $params['action'])), empty($params['pass'])? null: $params['pass']);
Renommez le fichier dans le dossier views "visits.png.thtml" au lieu de "visits.thml" et la methode dans analytics_controller.php "visitspng" au lieu de "visits", et le tour est joué.
--ben.12
Edite: après quelques testes supplémentaires, il y a encore des incompatibilités entre Artichow et cakephp sous PHP5. Qui peuvent être vite résolus, mais je vais pas donner le détaille, le message est déjà assez long comme ça.
Merci pour toutes ces infos ben. 12,
Chez moi ça ne marche pas malgré tous tes réglages.
J'ai le droit à ça:
L'image “http://jeanviet.info/cake/index.php/analytics/visits.png” ne peut être affichée car elle contient des erreurs.
Je me demande s'il n'y a pas une bibliothèque GD2 à installer...
Je suis chez OVH,
Tu sais comment je dois faire pour installer GD2 ??
A oui j'ai oublier de préciser, il faut activer la librairie GD2 de php ^^.
Mais c'est pas sensé être cette erreur dans ce cas.
Je te suggère de commenter la ligne "$graph->draw();" dans visits.png.thtml pour avoir le détail des erreurs php.
Sinon, pour info, pour activer gd2 il faut être l'administrateur du serveur (impossible sur un serveur mutualisé), éditer le fichier php.ini de php et enlever le ";" devant "extension=php_gd2.dll" (sous windows, sous linux ça doit être un .o).
This looks very nice. My French is a little rusty, it will take some time to comprehend the explanation!
I'm glad to see the output is png, as my php build supports that (I can't get GD to support jpeg on apache 1.3/OS X).
Once I have copied the code and have some idea of what I'm looking at, I will most likely be back with more questions.
Thanks very much, Ben.12 and Jeanviet! Michael
hello all,
I don't expect to get out of doing any work, but I would like to point out Ben.12's edit of dispacher.php results in
Parse error: syntax error, unexpected T_IF, expecting ')' in /blah/cake/app/webroot/webanalytics/cake/dispatcher.php on line 178
I'm looking into it myself.
Thanks,
Michael
Jeanviet,
this seems crazy, but: when I copy your files to a Windows server (IIS 6.0 with PHP/MySQL), I do see my site's statistics when I put debug $report in your analytics_controller.php, but the reports table has no data. I have confirmed I am using your files, changed only when I put my email address and password in. Do you have any ideas what to look for?
Thanks!
Michael
Ok, I am back!
I've placed the files as specified. I decided to switch to png to see how that works. The only difference is visitspng.thtml couldn't find artichow, so I moved artichow to the views folder and changed line 11 in visitspng.thtml to
require_once "artichow/LinePlot.class.php"
Instead of a nice chart, I get this!:
Notice: Undefined index: Consultations de page in G:\Inetpub\wwwroot\cake2\app\views\analytics\visitspng.thtml on line 8
Notice: Undefined index: Période in G:\Inetpub\wwwroot\cake2\app\views\analytics\visitspng.thtml on line 6
Notice: Undefined index: Visites in G:\Inetpub\wwwroot\cake2\app\views\analytics\visitspng.thtml on line 7
Notice: Undefined index: Consultations de page in G:\Inetpub\wwwroot\cake2\app\views\analytics\visitspng.thtml on line 8
Notice: Undefined index: Période in G:\Inetpub\wwwroot\cake2\app\views\analytics\visitspng.thtml on line 6
Notice: Undefined index: Visites in G:\Inetpub\wwwroot\cake2\app\views\analytics\visitspng.thtml on line 7
Notice: Undefined index: Consultations de page in G:\Inetpub\wwwroot\cake2\app\views\analytics\visitspng.thtml on line 8
Notice: Undefined index: Période in G:\Inetpub\wwwroot\cake2\app\views\analytics\visitspng.thtml on line 6
Notice: Undefined index: Visites in G:\Inetpub\wwwroot\cake2\app\views\analytics\visitspng.thtml on line 7
Notice: Undefined index: Consultations de page in G:\Inetpub\wwwroot\cake2\app\views\analytics\visitspng.thtml on line 8
Notice: Undefined index: Période in G:\Inetpub\wwwroot\cake2\app\views\analytics\visitspng.thtml on line 6
Notice: Undefined index: Visites in G:\Inetpub\wwwroot\cake2\app\views\analytics\visitspng.thtml on line 7
Notice: Undefined index: Consultations de page in G:\Inetpub\wwwroot\cake2\app\views\analytics\visitspng.thtml on line 8
Notice: Undefined index: Période in G:\Inetpub\wwwroot\cake2\app\views\analytics\visitspng.thtml on line 6
Notice: Undefined index: Visites in G:\Inetpub\wwwroot\cake2\app\views\analytics\visitspng.thtml on line 7
Notice: Undefined index: Consultations de page in G:\Inetpub\wwwroot\cake2\app\views\analytics\visitspng.thtml on line 8
Notice: Undefined index: Période in G:\Inetpub\wwwroot\cake2\app\views\analytics\visitspng.thtml on line 6
Notice: Undefined index: Visites in G:\Inetpub\wwwroot\cake2\app\views\analytics\visitspng.thtml on line 7
Notice: Undefined index: Consultations de page in G:\Inetpub\wwwroot\cake2\app\views\analytics\visitspng.thtml on line 8
Fatal error: Declaration of awGDDriver::init() must be compatible with that of awDriver::init() in G:\Inetpub\wwwroot\cake2\artichow\inc\drivers\gd.class.php on line 662
the cake2 installation is displaying my data just fine in other views, so I don't think the cake install is to blame.
Any ideas?
Thanks!
Michael
Hi Michael,
You just have to change the french names by english / us names.
In the txt file of Ben.12:
Day for Période
Visits for Visites
Pageviews for Consultations de page
I send you the english version... and Ben.12 work have been wrote in french (for google analytics metrics)
ok, I changed from French to English whenever possible in visitspng.thtml. Not much inprovement. The fatal error at the bottom is what makes the most nervous:
Notice: Undefined index: Day in G:\Inetpub\wwwroot\cake2\app\views\analytics\visitspng.thtml on line 6
Notice: Undefined index: pageviews in G:\Inetpub\wwwroot\cake2\app\views\analytics\visitspng.thtml on line 8
Notice: Undefined index: Day in G:\Inetpub\wwwroot\cake2\app\views\analytics\visitspng.thtml on line 6
Notice: Undefined index: pageviews in G:\Inetpub\wwwroot\cake2\app\views\analytics\visitspng.thtml on line 8
Notice: Undefined index: Day in G:\Inetpub\wwwroot\cake2\app\views\analytics\visitspng.thtml on line 6
Notice: Undefined index: pageviews in G:\Inetpub\wwwroot\cake2\app\views\analytics\visitspng.thtml on line 8
Notice: Undefined index: Day in G:\Inetpub\wwwroot\cake2\app\views\analytics\visitspng.thtml on line 6
Notice: Undefined index: pageviews in G:\Inetpub\wwwroot\cake2\app\views\analytics\visitspng.thtml on line 8
Notice: Undefined index: Day in G:\Inetpub\wwwroot\cake2\app\views\analytics\visitspng.thtml on line 6
Notice: Undefined index: pageviews in G:\Inetpub\wwwroot\cake2\app\views\analytics\visitspng.thtml on line 8
Notice: Undefined index: Day in G:\Inetpub\wwwroot\cake2\app\views\analytics\visitspng.thtml on line 6
Notice: Undefined index: pageviews in G:\Inetpub\wwwroot\cake2\app\views\analytics\visitspng.thtml on line 8
Notice: Undefined index: Day in G:\Inetpub\wwwroot\cake2\app\views\analytics\visitspng.thtml on line 6
Notice: Undefined index: pageviews in G:\Inetpub\wwwroot\cake2\app\views\analytics\visitspng.thtml on line 8
Fatal error: Declaration of awGDDriver::init() must be compatible with that of awDriver::init() in G:\Inetpub\wwwroot\cake2\artichow\inc\drivers\gd.class.php on line 66
It looks like you're new here. If you want to get involved, click one of these buttons!