You are not logged in.

Dear visitor, welcome to krpano.com Forum. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

nelk

Intermediate

  • "nelk" started this thread

Posts: 358

Location: Paris

  • Send private message

1

Tuesday, May 12th 2009, 12:26pm

plugin for analytics

Hi,

It could be great to have a plugin for google analytics to know how many panoramas are viewed, the most viewed...

I think it's not very difficult to do it with some javascript.

Somebody has ever work on something like this ?

Regards,
VideoStitch, a video stitching engine / blog sur les visites virtuelles ( french ).

Shanti

Intermediate

Posts: 301

Location: Puerto Vallarta

Occupation: Web Developer

  • Send private message

2

Tuesday, May 12th 2009, 8:51pm

It depends, if you have multiple panoramas (virtual tour) or just single panoramas on each page.

if you use single panoramas or just want to know what virtual tour they visited without knowing the exact panoramas they looked then just put the regular analytics JS code on the page that holds that particular panorama.

if you are using multiple panoramas (virtual tour) on a single page then I am afraid Analytics won't help you there since it will only tell you the page they opened and not what panoramas they viewed but if you are familiar with PHP you can create a "image stream" and add the code to a MySQL database and have basic statistics.

but you will need to have all of your panoramas added to a MySQL database first.

something like on MySQL

Source code

1
2
3
4
5
6
 CREATE TABLE `yourdatabse`.`panoramas` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`name` VARCHAR( 255 ) NOT NULL ,
`pano` VARCHAR( 255 ) NOT NULL ,
`visits` VARCHAR( 255 ) NOT NULL
) ENGINE = MYISAM 


then populate this database

after this create a php file to "stream" the image and count the visits.

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php

//a function to connect to MySQL its a bit old, but works :)
function connect($SQL) {

$dbhost = 'localhost';
$dbname = 'yourdatabse';
$dbuser = 'youruser';
$dbpasswd = 'yourpassword';

// we select a the database and connect to it
$conex = mysql_connect($dbhost,$dbuser,$dbpasswd) or die ("no se pudo conectar???");
mysql_select_db($dbname, $conex);

// this wil execute the query
  $resultado = mysql_query($SQL,$conex);
if (!mysql_errno()){
 return $resultado;
 } else {
echo "MySQL error ".mysql_errno().": ".mysql_error()."\n<br>When executing:<br>\n".$SQL."\n<br>";
die();
 }
 }

// I got this from the internet, sorry I don't remember where, but I modified to fit Krpano needs

function LoadJpeg($imgname)
{
    /* Attempt to open */
    $im = @imagecreatefromjpeg($imgname);
    
    /* See if it failed */
    if(!$im)
    {
        /* Create a black image */
        $im  = imagecreatetruecolor(150, 30);
        $bgc = imagecolorallocate($im, 255, 255, 255);
        $tc  = imagecolorallocate($im, 0, 0, 0);
        imagefilledrectangle($im, 0, 0, 150, 30, $bgc);

        /* Output an error message */
        imagestring($im, 1, 5, 5, 'Error loading panorama', $tc);
    }

    return $im;
} 
 
$sql = "SELECT * FROM panoramas where id = ".$_GET['id'];
$result = connect($sql);


 
header('Content-Type: image/jpeg');
$row = mysql_fetch_array($result);

//update the visits
$sql = "update panoramas set visits=visits+1 where id = ".$row['id'];
connect($sql);

$img = LoadJpeg($row['pano']);

imagejpeg($img);
imagedestroy($img);
?>



then on krpano you call it like this

Source code

1
2
3
<action name="loadpano1">
loadpano(null,sphere=panoload.php?id=1,KEEPALL,BLEND(2));
</action>


this code has not been tested, most of it I modified for this post also this code can be expanded to use cubes or any other panorama type, even multires, but I think that would be a lot or overwork for the server.

hopefully I explained myself and this could help others, but if you run into problems let me know I will try and help *smile*

nelk

Intermediate

  • "nelk" started this thread

Posts: 358

Location: Paris

  • Send private message

3

Wednesday, May 13th 2009, 12:27am

Hi Shanti,

Thanks for your answers.

I know PHP a little bit, I think I can understand this code (I'll have a look tomorrow)

But do you know there is a API for Google Analytics for Flash ? I've just found it.Have a look here and here.

I don't know yet if this API can be easily embed for stats of krPano
VideoStitch, a video stitching engine / blog sur les visites virtuelles ( french ).

Shanti

Intermediate

Posts: 301

Location: Puerto Vallarta

Occupation: Web Developer

  • Send private message

4

Wednesday, May 13th 2009, 6:01am

ohh, nice I did a search a while ago and didn't find a way, this looks cool I am going to try and look at it maybe a plugin could be made of this :)

Shanti

Intermediate

Posts: 301

Location: Puerto Vallarta

Occupation: Web Developer

  • Send private message

5

Wednesday, May 13th 2009, 8:19am

here it is :) the very first and limited version of this plugin :)

http://www.mundopano.com/test/tour.html

I can't actually know if its sending the data to my analytics account since i think it takes a few hours so I will say its *UNTESTED*

but it seems to work correctly :)

I will upload it to the plugins section :)

EDIT: I will actually wait until the data appears on my google analytics just to make sure everything works as it should, then I will upload it

Enjoy

This post has been edited 1 times, last edit by "Shanti" (May 13th 2009, 8:37am)


nelk

Intermediate

  • "nelk" started this thread

Posts: 358

Location: Paris

  • Send private message

6

Wednesday, May 13th 2009, 10:20am

Oh, great ! :-)

Can you tell us a little bit what do you parse and what do you send to analytics server ?

(edit: this is my 100st post ! :-) )
VideoStitch, a video stitching engine / blog sur les visites virtuelles ( french ).

nelk

Intermediate

  • "nelk" started this thread

Posts: 358

Location: Paris

  • Send private message

7

Wednesday, May 13th 2009, 10:32am

I don't know wet what you have implemented, the only thing I see is

Source code

1
<plugin name="analytics" url="analytics.swf?theTrackerCode=UA-2112336-5&DebugMode=1" />


But I think we should put the UA code in a separate variable, something like

Source code

1
trackerCode="UA-123456"


And ... if we can put a prefix, it could be great too ! like

Source code

1
prefix="/pano/"


The main idea of the prefix is to use the search function of analytics to show only the /pano/ part.

I use it for the outbound links, and it works very well.

My outbound link are generated like this

Source code

1
<a onclick="javascript:pageTracker._trackPageview('/outbound/article/www.kubische-panoramen.de');" href="http://www.kubische-panoramen.de/ppg11">Panoramagalerie</a>


And when somebody click on this links, analytics counts it and I know how many people clicks on this link ... inside /outbound/ part.

It could be great to have the same things for /pano/

Have a look here or here.

Anyway, you program very fast, thanks ! ;-)
VideoStitch, a video stitching engine / blog sur les visites virtuelles ( french ).

Shanti

Intermediate

Posts: 301

Location: Puerto Vallarta

Occupation: Web Developer

  • Send private message

8

Wednesday, May 13th 2009, 7:19pm

The reason you only see that line is because its a plugin, everthing related to that is in there and you call it with this

wait(LOAD);
call(events.trackthis,/spot 1);

inside an action

the reason for the wait is because the plguin needs some "start" time, and the very first panorama gave me errrors, so i just put it in the spot 1 action.

and Its way easier to just pass the variables like I am doing right now, using the querystring and its the same thing as variables for the user.

the prefix is a good idea, I will implement it and then upload the plugin the data showed on my account :D


Regards

Shanti

Intermediate

Posts: 301

Location: Puerto Vallarta

Occupation: Web Developer

  • Send private message

nelk

Intermediate

  • "nelk" started this thread

Posts: 358

Location: Paris

  • Send private message

10

Wednesday, May 13th 2009, 8:18pm

call(events.trackthis,/spot 1);


You need the call action ? It's not necessary since 1.0.7, is it ?

http://krpano.com/docu/actions/#call
VideoStitch, a video stitching engine / blog sur les visites virtuelles ( french ).

Shanti

Intermediate

Posts: 301

Location: Puerto Vallarta

Occupation: Web Developer

  • Send private message

11

Wednesday, May 13th 2009, 8:22pm

I tried it without and got an error *sad* , maybe I did it wrong, but feel free to test it *smile* using the "o" key on the keyboard and debug mode on you should be able to see whats going on :)

nelk

Intermediate

  • "nelk" started this thread

Posts: 358

Location: Paris

  • Send private message

12

Wednesday, May 13th 2009, 8:54pm

No problem for me with this

Source code

1
events.trackthis(%1);
VideoStitch, a video stitching engine / blog sur les visites virtuelles ( french ).

ClearTours

Beginner

Posts: 18

Location: Naperville, IL USA

Occupation: Architectural Photographer

  • Send private message

13

Friday, May 29th 2009, 5:54am

Just thought I'd pass along this link to the Google Analytics for Flash

http://code.google.com/apis/analytics/do…ckingIntro.html

I've have this running inside of my krpano portfolio plug-in at http://cleartours.com/portfolio that tracks which pano people select. Its very helpful and Its easy for me to see how much time people are spending on each one of the panos.

Lee

---

Lee Evans
Cleartours, Inc.

Shanti

Intermediate

Posts: 301

Location: Puerto Vallarta

Occupation: Web Developer

  • Send private message

14

Friday, May 29th 2009, 7:43am

Clear: this plugin uses the GA component, i am thinking its the same thing?

anyways, I really like your sliding thumbnails, is that a plugin you created ?

ClearTours

Beginner

Posts: 18

Location: Naperville, IL USA

Occupation: Architectural Photographer

  • Send private message

15

Saturday, May 30th 2009, 8:31pm

Yup, same thing... Sorry for the duplicate post.

Quick off-topic response... Plug-in was originally from http://flashden.net/item/full-screen-xml-gallery-vrt-v1/9091 that I ported to AS3 and made some mods on. If you need more details just send me a email or message

Lee

---

Lee Evans
ClearTours, Inc.

vincen

Trainee

Posts: 67

Location: Grenoble, France

Occupation: Photo, ski, walk, outdoor activities

  • Send private message

16

Monday, November 2nd 2009, 2:52pm

Still didn't succeed to get that module for Google analytics to work :( I included as explained by Shanti but nothing appears in my Analytics unless I know panoramas have a bunch of visits if I check webstat of my server !

Any idea what might be wrong ?

Thanks

Vincèn
http://www.skivr.com (my blog)
http://magasin.skivr.com (my online shop for all panoramas and photography stuffs)

vincen

Trainee

Posts: 67

Location: Grenoble, France

Occupation: Photo, ski, walk, outdoor activities

  • Send private message

17

Friday, February 19th 2010, 1:33pm

Still nothing working correctly for Google Analytics to track correctly panos viewed during a virtual tour ?

Thanks

Vincèn
http://www.skivr.com (my blog)
http://magasin.skivr.com (my online shop for all panoramas and photography stuffs)

VN2009

Professional

Posts: 1,334

Location: Duluth MN

  • Send private message

18

Tuesday, October 5th 2010, 11:31pm

shanti this kicks much ass ! once you get it all figured out it is very easy to implement.

Vincen - i think this would work i will test tomorrow and let you know.

add this to your primary xml

<plugin name="analytics" url="analytics.swf?theTrackerCode=UA-1234567-1&Prefix=/cpdemo/&DebugMode=1" />

add a generic plugin to each pano's xml.

<plugin name="googleA" keep="false" onloaded="call(events.trackthis,/pano1)" />

<plugin name="googleA" keep="false" onloaded="call(events.trackthis,/pano2)" />

that should log visits to each pano and put them under cpdemo/pano1 and cpdemo/pano2


EDIT: this does not work. seems i can track first pano and everything else i want except additonal panos :(

This post has been edited 1 times, last edit by "VN2009" (Oct 5th 2010, 11:44pm)


Similar threads