Jump to content

Log user activity


The Little Guy

Recommended Posts

Hello again!

 

Huh? Sorry for double-posting. But after having breakfast and a shower here I think I will integrate that idea to my site as well! Though! I have a few Javascripts through now, and I am into these files now:

http://www.w3.org/TR/XMLHttpRequest/

http://www.w3schools.com/xml/xml_http.asp

 

I think am going to post my first working result later on. Well my wife is awake, and it is nearly the local time for lunch here! And onions get not cut by themselves. *cough*

 

Regards,

 

MPeter

Link to comment
Share on other sites

Hello, again.

 

First, sorry for triple-posting. But no-one else did post something with code so far. And as I said here this is my first workaround about. Hey! I need a few more counts on my posts when I see 5,000+ on some users. j/k

 

File #1:

<html><head>

<title>This File has a Title!</title>

<script type="text/javascript">
var i = 0;
function UserXMLHttpRequest () {
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.open("GET","note.xml",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;

MyTimestamp=
new Date().getTime();

document.getElementById("userstatcontent").innerHTML=
'Hello '
+xmlDoc.getElementsByTagName("userstatcontent")[0].childNodes[0].nodeValue
+'&mtime='+MyTimestamp+' World!';

i = i + 1; // :-)

if (i < 9)
window.setTimeout("UserXMLHttpRequest()", 10000);
}
</script>

</head>
<body onload="javascript:UserXMLHttpRequest();">

<h1>Test-File</h1>

<p><b>userstatcontent:</b> <span id="userstatcontent"></span></p>

</body>
</html>

 

File #2:

<note>
<userstatcontent>?some=text</userstatcontent>
</note>

 

It is based upon the Tutorial from here (with minor changes so far):

http://www.w3schools.com/xml/xml_http.asp

 

Well, I think things like window.innerWidth and window.innerHeight - which may change by some reason - can be added easily to this coding. Respectfully all the data which will appear, the use of a Javascript-Cookie I do see as recommended.

 

These are the things I will try to add for myself next. When someone has any additional ideas and resources to link - please - do not hesitate, I got really greedy about this here, and I feel there must be something more than only this!

 

I want to calculate user activity. I want be able know how many hours a user has been using my site, but if a user stays logged in and doesn't do anything for an hour, I don't want to add that hour of nothingness to their count of active hours. Any suggestions on how I should go about doing something like this?

 

ps: Thank you for inspiring me so much. It was a very long time ago I have read such a beautiful description, really. And my native language is not english. A Big Thank You! It was great fun to read up these technical things once again, and to write something useful (for me). And I do hope I could have given an answer.

 

Regards,

 

MPeter

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.