The analytics.js library allows you to send or share data about your website users. For example, when a visitor fills a form or logs in, the collected data can be sent to AFS Analytics. These will be attached to the user's profile and will appear on each of his visits.
2. Sending data to server: The transmission to the server is done through the command SEND followed by the key visitor.
Note: If the AFS Analytics WordPress plugin is installed on your website, the data will be automatically sent when users log in. These features are only available with the Silver and Gold plans.
I.Data Storage
The SET command is used to store the data. The command accepts object or string indicating the variable to set.
Syntax:
aa("set","visitor",[object])
Or:
aa("set","visitor.[variable]",[value])
Example:
aa("set","visitor",{firstname:"christophe";lastname:"Durand"};
Which is the equivalent to:
aa("set","visitor.firstname","Christophe");
aa("set","visitor.lastname","Durand");
The different fields:
All fields are optional.
job: "create" for profile creation. "update" for profile update. "delete" for profile deletion. By default, it is set to update mode. The "create" mode saves the data only if it’s a new user. The "update" mode updates the data or creates the profile if it does not exist. The "delete" mode deletes the user's profile.
logged: The visitor has logged-in to the website. Value must be 1 or greater.
afsid:The unique identifier of the visitor created by AFS Analytics. By default, it's the current visitor.
yourid:You can define your own unique identifier.
username: This is the username used for the login.
displayedname: The name to display on the visitor list. By default, the username is displayed.
role: The role of the user. It's a string, example: administrator, member, etc. It's up to you to define it.
firstname: The first name of the user.
lastname: The last name.
company: The name of the company.
address: Number and name of the street.
addressplus: Address line 2.
city: The city.
state: The state or region
country: The country.
zipcode: Postal code.
email: Email
phone: The phone number.
sms: The mobile phone number that can receive SMS
birthday: The date of birth in the form yyyy-mm-dd.
sex: M for men, F for women.
photourl: URL of the picture showing the user (https only).
yournote: Your notes about the user.
yoururl: Link to attach to the identifier you provided: Yourid.
followlist: List(s) attached to the user. This can be the numeric identifier of the list, or the name of the list. If there are multiple lists, they must be separated by a comma. You can create the lists, or find their identifier on the visitor profile box by clicking .
II. Sending data to server
The data transmission is done with the SEND command. After the transmission analytics.js resets all data values.
Syntax:
aa("send","visitor");
Here is an example:
data=new Object() ;
data.job="update";
data.firstname="Christophe";
data.lastname="Durand";
data.username="chris277";
data.displayedname="The Boss";
data.birthday= "1989-12-31";
data.photourl="https://www.afsanalytics.com/images2/profile/demo.png";
data.role="Administrator";
data.followlist="Developer team, support";
aa("set","visitor",data); //set visitor data
aa("create", "xxxxxxxx", "auto");
aa("send", "pageview");
aa("send","visitor");
When a visitor logs in
By way of exception, when a visitor logs in, the Send visitor command is not required after the setting of the logged variable (visitor.logged), if the variable is defined before the line sending page data.
Here is an correct example:
aa("create", "xxxxxxxx", "auto");
aa("set","visitor.logged",1); //not needed to add a send visitor line.
aa("send","pageview");
By AFS Analytics, Saturday, May 9, 2020