I'm a new user to Hype. I have a client that would like to build a Poster Interactive where a user can view a medical poster and click on certain links to view images or PDFs. They would like to have some data collecting (what items viewed, how long).
I've read that I can do this with Google Analytics if the program is hosted online. Is there a way to do this if the program is running on a computer via the web browser? If a connection is needed, that's an option, just not sure if GA can be used without the program hosted on a server.
This is not really what GA was built for, but it is possible.
...Has more info.
This would work best if the domain was setup on your local computer (something like mycomputer.local).
Essentially, the property domain of the GA code will need match the localhost domain. More info from:
Once you have this setup, you can track events like timeline triggers with this tutorial, but it's not going to give you great transparency over what the person is doing in a Hype document within a scene: Tracking visits, events, and actions with Google Analytics
Google analytics tracking code can work with file:/// URLs locally, but I'm not really sure what it can/can't track with that and how it shows up in the console. I see there are some questions/answers about how to do this properly, like:
However an internet connection is definitely needed, that's how it communicates with the server! It just doesn't require your files to be hosted from a web server.
function saveData(data) {
var xhr = new XMLHttpRequest();
xhr.open('GET', 'file.php?json=' + JSON.stringify(data));
xhr.send();
}
/* Example of defining data: */
var data = [
['firstname', 'lastname', 'age'],
['John', 'Doe', '23'],
['Jane', 'Doe', '25']
];
/* Example of calling the function: */
saveData(data);
If you rather need Python to save stuff:
import csv
import json
import sys
import os
json_data = sys.argv[1]
data = json.loads(json_data)
$week = date('W');
$file = fopen("week_$week.csv", "a");
foreach ($data as $line) {
fputcsv($file, $line);
}
fclose($file);
Beware that there is no authentication and this works with a flat file numbered by the week. But given a closed Kiosk this might be viable enough.