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
|
Quellcode
|
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.
|
Quellcode
|
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
|
Quellcode
|
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