Easier Google Spreadsheet Visitor Logger

One of the most popular articles on this site is Log your visitors to Google spreadsheet, which I wrote in 2012, and which Zuza Ritt updated the following year.

Here’s an easier way to do it, and the script to go with it.

Step One: Create the form

Sign in to your Google Drive (formerly Google Docs) account, click on the big red “Create” button and select “Form.” Name it something like “Visitor Tracker” or “My Guestbook” — the title doesn’t matter.

Then add exactly two questions, both plain text fields. Name the first Location and the second Avatar.

Create new form -- step one

You might see some settings options at the top of the form — leave them all unchecked.

Step Two: Get the special Google Forms link

Now look up at the menu, and under “Responses” click on “Get Pre-filled URL.”

Prefill form -- step two

Under “Location” type the word “Location.”

Under “Avatar” type the word “Avatar.”

Hit “Submit.”

You will get a long link to copy. Copy that link.

Save link -- step three

Step Three: Use that link to create the visitor logger

Now go in-world. Create any old object. Paste the link you copied into the description for that object.

Then cut and paste the following script into it:

Easier Google Spreadsheet Visitor Logger

The script pulls all the info it needs out of that link, and doesn’t need any further editing or configuration.

This script records a time stamp, and saves both the region name and the grid name. So you can use it on multiple regions. Or, say, if you have stores on several grids, you can track all of those visitors in a single spreadsheet.Visitor spreadsheet

This script records a time stamp, and saves both the region name and the grid name. So you can use it on multiple regions. Or, say, if you have stores on several grids, you can track all of those visitors in a single spreadsheet.

Next, I plan to add in a landmark giver and put it into a welcome medallion that would go on the ground in the middle of the welcome area.

When that’s done, I’ll put the whole thing up on the Kitely Market.

Visitor Logger

A hard-coded alternative

For some reason, once I moved the script to another grid, it stopped working. In particular, the osGetGridName command returned an error message instead, and the llParseString2List function insisted on working incorrectly — breaking up a number into two pieces even though there was no separator or spacer there. (If anyone has heard of this happening, please let me know!)

So here’s an alternative to the above script in case other people have similar issues. Instead of copying-and-pasting the long submitted form URL, you have to open up the script and paste it into the first three lines of the script.

Parsing the form URL

Copy everything in the first half of the URL — up to, but not including “/viewform?…” and paste it into the first line. Do not include the slash. The first line of the script currently says the following:

string FrontPart = "https://docs.google.com/forms/d/#########################################";

So this script will not work out of the box — you will have to update it with your own info.

Then the second line in the script sets the LocationKey, which is the next longer number in the URL, the third line sets the AvatarKey, which is the last long number in the URL.

Finally, the fourth line lets you set the grid’s name.

So you still have to edit the script, but at least you don’t have to look around for where to make the edits. By hardcoding this data, it also makes the script shorter and less liable to break.

It still looks up the current region name, so as long as you have it on the same grid, once you have it updated with your own info you can just copy this script around to any object that needs it.

Download the script here: Easier Google Spreadsheet Visitor Logger — hardcoded

Maria Korolov