Tip

Notes client view hit counter

Have you ever inherited an application that you did not build? It's big, slow, and for some reason there are 95 views in it, many of which are named 'Copy of ...', 'Another Copy of ...' and 'zDeveloperView...' that you suspect are not being used any more. Would it be nice to know if the user population is still using a particular view? Getting rid of those extra, unused views can reduce the size of the database view index, helping your application's performance. Here is a simple method to determine if a view is being used, and how often.

Note: This method only counts user hits for users with a database access level of Editor or above, as Readers and below cannot edit the Profile Document.

Create a profile form. I will call it ViewHitProfileForm. Create a two-column table and enter all the view names and one field next to each view name that you need to track. The fields can be editable - text. Let us say we are tracking three views: View1Hits
View2Hits
View3Hits
Save the form.


Create an agent to edit the profile document.
Name: Edit ViewHitProfileForm
When should the agent run? Manually from Agent List
Which documents should it act on? Run once. (@Commands may be used)
Run Formula: @Command([EditProfile];"ViewHitProfileForm") Save the agent and run it to create and edit the profile document. You must enter a zero in each field or you will encounter errors. Save the newly created profile document.

Go to the design of each view and enter the following code in the PostOpen event:
@If(@TextToNumber(@Left(@UserAccess(@DbName);1)) < 3; Return(""); "");
temp:=@TextToNumber(@GetProfileField("ViewHitProfileForm";"View1Hits")) +1;
@SetProfileField("ViewHitProfileForm";"View1Hits";@Text(temp))
Make sure to change the number on View1Hits to 2 and 3, depending on the view.
This code will retrieve the number of view hits from the profile document, increment it by one and then set it again in the profile document.

Any time you want to see how many hits the views have, simply run the agent and print the profile document. You can also reset the counters to zero to collect monthly or weekly statistics on view use. This can help focus future development efforts on the most heavily used views and also help you eliminate infrequently used views without guesswork.

If you need to track the last user of the view you could enter another field on the profile form called View1User. Then you could add the following code to record the username of the person who last accessed the view.
@SetProfileField("ViewHitProfileForm";"View1User";@Name([Abbreviate]
;@UserName))

This was first published in June 2001

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.