Sansar Docs
Ask or search…
⌃K

Visitor Tracker

Example Scripts: Visitor Tracker
The example script, Visitor Tracker (VisitorTrackerExample.cs), tracks the number of visitors that visited your experience over the course of a session. Grab the file at the download link at the end of the page.
Instructions
Here is a step-by-step guide to using the script:
  1. 1.
    Download the script file from the download link at the end of this article.
  2. 2.
    Follow the instructions provided in Working with scripts to upload the script and add it to an object.
  3. 3.
    Open the object's Properties panel and go to the Script Settings section.
  4. 4.
    At the bottom of the object's properties panel is a Script Settings section. Set the parameters according to the Script parameters section of this article.
  5. 5.
    Once you have finished these steps, your script is ready. Save and build your scene.
  6. 6.
    If you want to verify if the script is running correctly, visit the built scene.
  7. 7.
    While visiting the scene, open the Chat app.
  8. 8.
    In the chat field, type the command that you have set. In this example, /visitors. This prompts the script to run and a message box opens showing a log of all the visitors who have visited the scene.
    chat_type.png
Script parameters
​
vistor_tracker.png
​
The parameters for Visitor Tracker
Parameter field
Description
OwnerName
If you prefer to have the script listen only to your commands, set the OwnerName to your display name. Otherwise, leave it blank to let anyone issue the command.
VisitorListCommand
The word you would like to use as a command. For this example, let's use "/visitors" as a command.
Notes:
A few notes for the VisitorTrackerExample.cs example script:
  • The script logs the visitors who came and visited your experience.
  • This script only runs until an experience session ends. Once it ends, the tracker resets and all data is lost.
  • An experience session ends when your scene has been empty (no visitors) for some time.
Have more questions? Join our Discord!​