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

Related Posts

maria@hypergridbusiness.com'

Maria Korolov

Maria Korolov is editor and publisher of Hypergrid Business. She has been a journalist for more than twenty years and has worked for the Chicago Tribune, Reuters, and Computerworld and has reported from over a dozen countries, including Russia and China.

  • I like this and will try to fix one for myself later today…ty-)

  • Ai Austin

    I wonder if the problem on another grid may be because the object description is being truncated to 64 or 128 characters when taken to inventory on that grid, or to persistent storage of the object. It may work at initialisation time where a prim can have a description of 255 characters and subsequently get chopped off. The default now is CHAR(128) which is much shorter than the Google Docs form URL, and I have seen some chopping of the description field on grids down to CHAR(64). I am not sure why the description DB field is different in different places in the Database!

  • Very cool update. Thanks.

    I’ve been running the original script on Pathlandia ever since you first wrote about it. Going strong for over 2 years now. 😉 http://bit.ly/pathlandia-logs

  • well, it seems simple enough but perhaps still to difficult for the slow minded of us [or just for me]…anywho, I guess I did something wrong. I read this several times but all I show in my google spreadsheet is this.

  • OK, after several days using this, I love it! You asked for ideas and I would like it if it could give a simple greeting and even better if different for first timers than recurring.

    • I am also consider adding a landmark giver to this, and then putting it up on the Kitely Market.

      Do folks have any other features they’d like to add?

      To check if someone is a new visitor or not, I’m considering having the script gather up names until the list of visitors is up to 100 unique people, dumping it to a notecard, then starting the list over again. (In OpenSim, we can create notecards! Yeay!) That way, the local script won’t have to check the spreadsheet to see if someone had stopped by before, which is slow, and also there’s only so much web text you can download before running out of memory.

  • Rich Reynaud

    On the Second Life grid I had to use llEscapeURL() for the Location and Avatar strings when building the URL. Otherwise any location or avatar name that contained a space would return a response code of 499 and fail to post the data to Google.

  • hey, I have been using this for some months now, and I do like it a lot, but, I could not find where the sensor distance is in the script…I would like to increase it as it does not cover my entire region.

    Also, I have this nc lm giver script which notifies me in email when touched. I would love to have just the part that sends an email to me and also if it could be simply added into the script sensor aspect.

    In this way I could get an email with any visitors who drop in.

    Any luck on this?

    edit as I forgot to add that script…lol

    “//lm n nc giver

    // remove this number for the script to work.

    // This script will automatically detect the name of you landmark and notecard.

    // Just ensure that they are the only 2 things you put in the box with this script.

    // This is the text you wish to be displayed above your object, leave blank if

    // you do not wish for anything to be displayed. To make a new line of text,

    // add ‘n’ to your text to tell the script to start a new line.

    string HText = “Exhibition Info”;

    // This is the color you wish for the hover text to be displayed as. It is

    // currently red.

    vector Color = ;

    // This is the transparency of the HoverText, 1 is solid, 0 is Transparent.

    float Alpha = 1;

    //________________________________________________________________________

    default

    {

    state_entry()

    {

    llSetText(HText,Color,Alpha);

    }

    touch_start(integer total_number)

    {

    llSay(0, “Thank you for requesting this information”);

    llGiveInventory(llDetectedKey(0),llGetInventoryName(INVENTORY_LANDMARK, 0));

    llGiveInventory(llDetectedKey(0),llGetInventoryName(INVENTORY_NOTECARD, 0));

    llInstantMessage(llGetOwner(), “LandMark giver at ” + llGetRegionName() + ” has just been used by ” +

    llKey2Name(llDetectedKey(0)) + “!”);

    }

    on_rez(integer start_param)

    {

    llResetScript();

    }

    }

    • It looks like the range of the sensor is on this line, line 28 or so, up top in the global variables:

      float range = 10.0; // in meters

      If it works in OpenSim like in Second Life, you should be able to go up to 96 meters. Which is ALMOST a whole region.

      Meanwhile, there’s already a “touch start” section in my script. You should be able to cut your script into two parts — the variable definitions, which will go up top, with my variable definitions, and the touch start section, which would go inside my touch start section. You might have to play around with it a little bit to make sure it works — the tricky part is knowing which lines you can leave out because they’re already there in my script!

      • ok, I just changed that 10 to 96 [I kinda think it can be higher but not sure enuf to try…tho I guess I could…the sky won’t fall].

        The rest I have no clue about. I can do very little with scripts. I could add it in if someone wants to, and can, add it to the script so I could just drop it in.

        No big deal tho, just a little thing I would like to see added.

        • Gayngel

          You can replace the sensor with llGetAgentList(AGENT_LIST_REGION) on a timer.

          • ah, an old post here but I still use the script. I don’t know how to add that in nor where and ty

          • Gayngel

            I’ll post an example once I get it working.

          • cool, thank you Gayngel… this may be getting a bit needy, but is there a way to add send to email code when a person comes into my region, in that same script? and I guess that getagent code will cover vars also?

            I will be around to check that code as soon as you get around to it.

          • Vinstor

            Just saw this, Minetheree. You can set Google to send you an email whenever the form response sheet is updated. (I use a Google form at work for equipment repair requests and have it set to notify me of all new responses.)

          • Ah, Hi, I just did that. My problem is now that the page does not auto populate in real time, I have to do it myself which defeats the purpose of emailing me upon updates as I see it already. Thoughts?

          • ok, this works just fine, thank you-)

  • I noticed that, when posting the full URL into my description field, the end part gets cut off.

    So instead I used the “Easier Google Spreadsheet Visitor Logger — hardcoded” — http://www.hypergridbusiness.com/wp-content/uploads/2014/10/Easier-Google-Spreadsheet-Visitor-Logger-hardcoded.txt

    And just cut-and-pasted the three important numbers into the top of the script.

    Now it worked fine. If your URL is too long to fit, you might trying doing that, as well.

    I created a brand-new form and in-world visitor logger object to test it out, and the only change I noticed is that the “Get Pre-filled URL” option is now at the very top right, under the three dots.

  • Alex

    Though the llDetectedName(i) only works when dealing with the display name, but easier to just get their account name with llGetUsername(llDetectedKey(i)) so that you don’t have to deal with long display names that are several names/words long.