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 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. Follow me on Twitter @MariaKorolov.

33 Responses

  1. trrlynn73@gmail.com' Minethere says:

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

  2. ai.ai.austin@gmail.com' Ai Austin says:

    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!

  3. Pathfinder says:

    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

  4. trrlynn73@gmail.com' Minethere says:

    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.

    • trrlynn73@gmail.com' Minethere says:

      hmm…I asked in g+ for ppl to drop by and so far 1 did…it still shows just the timestamp…annoying-)

      • Are you using the first or the second version of the script? If the first, try the second option.

        As I mentioned in the updated text at the end of the article, I also had a problem when running the same script on a grid other than Kitely. So you might want to get the Google Docs URL and then pull the various pieces out. Email me directly if you have any problems — [email protected] — so that you don’t have to post your key id numbers here for everyone! Good luck!

        • trrlynn73@gmail.com' Minethere says:

          ok. I made the changes and that seems to have fixed the issue….i was not sure if i should leave the full URL in the description but it seemed logical to remove it.

          it did then show me on my spreadsheet so I guess it works…cool-)) ty

          • No, the second version of the script doesn’t pull from the description line at all.

            If anyone has any ideas of how to improve this and make it easier, I’d love to hear them!

  5. trrlynn73@gmail.com' Minethere says:

    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.

  6. email me at [email protected] and i’ll help debug it. Meanwhile, which version of the script are you using? You might try the second version.

  7. sl.richreynaud@gmail.com' Rich Reynaud says:

    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.

  8. trrlynn73@gmail.com' Minethere says:

    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;








    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)





    • 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!

      • trrlynn73@gmail.com' Minethere says:

        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.

        • gayngelresident@gmail.com' Gayngel says:

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

          • trrlynn73@gmail.com' Minethereé says:

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

          • gayngelresident@gmail.com' Gayngel says:

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

          • trrlynn73@gmail.com' Minethereé says:

            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.

          • vince.medlock@gmail.com' Vinstor says:

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

          • trrlynn73@gmail.com' Minethereé says:

            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?

          • trrlynn73@gmail.com' Minethereé says:

            ok, this works just fine, thank you-)

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

  10. aasimar0@gmail.com' Alex says:

    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.

  11. clmail1978@gmail.com' BrokenStuff says:

    Tried to set this up (Hard coded version) on SL grid and doesn’t seem to be working. Updated FrontPart, LocationKey, and AvatarKey as directed above. Only other things I changed was the range from 10 to 35. Is this created for OS only?

    • The first version of the script has an OpenSim-specific function in it: osGetGridName

      That’s because there are lots of grids in OpenSim.

      You can edit that line of the code.

      Replace: Location= llGetRegionName()+” on “+osGetGridName();

      With: Location= llGetRegionName()+” on Second Life”;

      Or use the second version of the script, which is hard-coded for a particular region.

      • clmail1978@gmail.com' BrokenStuff says:

        Does the region name that its located at need to be exact? The region I was trying to use it in is a multiple named region (Nautilus – Dido) which I put in there and it is still not posting to the sheet.

        • clmail1978@gmail.com' BrokenStuff says:

          Nevermind that. Looking at the script it shouldn’t matter. Im baffled.

          • I’ve never written a script on Second Life, so I’m not much help there, either. Any other readers out there who might know what’s happening? Or — could you try to replace the region name with text as well?

          • clmail1978@gmail.com' BrokenStuff says:

            I figured out what it is but im not sure how to fix it. I put llSay(0,URL); in the sensor and there is a break in the link because the region im on has the spaces in the name.

          • clmail1978@gmail.com' BrokenStuff says:

            I’m sorry Maria for the posting spree. Thebreak in link because of region name having spaces I fixed. Its my name (or any persons name with a space in it) now that has the issue since I have a first and last name separated with a space which is causing the link to break.

      • clmail1978@gmail.com' BrokenStuff says:

        I fixed it doing what Alex posted. Just took a bit to come to the conclusion that what he had posted was the same issue I was having (Broken link due to spaces in region and user names). Its working now. I added his strings and lists in then changed your sting URL = to this string URL = FrontPart + “/formResponse” + “?entry.”+LocationKey + “=” + Location +”&entry.” + AvatarKey + “=” + FirstName + LastName + “&submit=Submit”; That fixed the name issue and I just hard coded the region name in above.

  12. vince.medlock@gmail.com' Vinstor says:

    I just set this up on an OSGrid region. It took a bit of futzing and had to use the hard-coded version because I couldn’t enter the entire URL in the item description (a limitation of Singularity viewer?). Since all my logs will feed into the same database, though, this is not a problem. Thanks for sharing!