Visitor counter + Google spreadsheet, update for 2013

Update: At Oct. 8, 2014 Maria Korolov published new and easier way how to log visitors to Google spreadsheet. Please try her version first.

If you want to log visitors of your region or parcel to spreadsheet, it is possible even in new Google Drive. This howto is made for spreadsheets in August 2013 and it works properly.
You do not need any special skills like programming or inworld scripting.

1. step

Thanks to Maria Korolov, for the idea and very nice and descriptive article. Her instructions are part one. My howto explaining how to change the Google URL and inworld script to work with current Google forms.
Make your new Google form as described in article, get the form URL.
Read more info about script there, if you want. Download Maria’s script, if you would like to study the changes.

2. step

Bellow is my complete script for your inworld counter. Before you use it, you have to change some parts of script. It is not working as is!

Your current URL for view the form looks like this one:

https://docs.google.com/forms/d/XXXXXXXXXXXXXXXX/viewform

where XXXX… is your unique ID for this form.

You have to change several parts of script:

First line of script – insert your Google form ID above
string google_formkey = "XXXX...."; //MUST REPLACE with your own Google form key

Next part for change is explained by Maria – if you want log in your avatar.
If the owner of inworld object with script has to be logged, comment this line:
//if( llDetectedKey( i ) != llGetOwner() )

If you do not want to log in your avatar, let it uncommented:
if( llDetectedKey( i ) != llGetOwner() )

Tha last part is most tricky.
In my script you can find this line:
string URL = "https://docs.google.com/forms/d/" + google_formkey + "/formResponse" + "?entry.YYY=" + detected_name + "&entry.ZZZ=" + region_name + "&submit=Submit";

All blue parts has to be replaced by your values.
My values above representing this URL:
https://docs.google.com/forms/d/XXXX…/formResponse?entry.724632390=AVATARNAME&entry.57313582=REGIONNAME&submit=Submit

Devide your URL to following parts:
First part is before XXXX… (your unique ID), in my case "https://docs.google.com/forms/d/"
Next is your Google form ID, it is loaded at first line of script in string google_formkey
Add the rest of URL between Form ID and question mark, in my case "/formResponse"
Add ID of your entries. First one starting with question mark (?), other ones starting with ampersand (&)

How to find your entries IDs?
For some reason Google do not use neat entry IDs like “entry.1″ and “entry.2″ anymore, but some random numbers.
You can find it in HTML code of your form. On the form page rightclick on the word “Avatar” and find “Inspect element,” “Show source code” or similar option, depending on your browser. It shows the code and probably highlight the element of “Avatar.” See the picture bellow.
Find the IDs of your elements and replace them in your script – "entry.YYY" by Avatar value and "entry.ZZZ" by Region value.

GoogleForm

You can check the correct values even without scripting and logging inworld. Put together your URL with your values:
https://docs.google.com/forms/d/XXXX…/formResponse?entry.724632390=AVATARNAME&entry.57313582=REGIONNAME&submit=Submit

Replace AVATARNAME and REGIONNAME by any values you choose.
Insert URL into your browser and press Enter. If you get error message, you made a mistake. If your URL is right, Google thanks you for submiting your answer and you just manually insert first visitor to your spreadsheet!

Download sample script. Works in OpenSim.
Download Second Life version of script. (Escaped avatar name)

Insert script with proper values to your object inworld. It is done.

I hope this howto will be helpful. If you find very different Google form URL or if it does not work for you (and you are absolutely sure it is not your typo), let me know in discussion.

Leave a Reply to Rycon Cancel reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>