Count clicks in Portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā06-15-2019 08:11 AM
Hello Everyone,
Is there a way to count how many clicks made in the portal quick links.
Ex: We created widget in Service portal for the quick links using <a href="https://www.google.com/" id="link" target='_blank'>Quick Link 1</a>. So we want to count how many users are clicking on each link for monthly basis.How to count that number and save it into table (New table) in that way they can report on that also.
Thanks!
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā06-15-2019 08:20 AM
yes it is possible.
try the below:
IN HTML:
<div ng-mousedown="c.show($event)">Click this text with one of your mouse buttons to return a number.
<p>
0 = The left mouse button<br>
1 = The middle mouse button<br>
2 = The right mouse button
</p>
</div>
Client Controller:
function() {
/* widget controller */
var c = this;
c.show = function(event) {
alert("You pressed button: " + event.button);
}
}
this will alert everytime when a mouse is clicked inside your div.
you can add some tweaks to above code to fit your requirement.
-satheesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā06-15-2019 08:46 AM
Thanks Satheesh. So how to save that counts into a table? Do i need to use client controller to count and Server script to save the count in to a table?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā06-15-2019 09:16 AM
Yes you need to create a seperate function call for each link as you need count of each link.
Yes you need a table to store the counts.
Check the below link to find an example for updating a value in table from widget.
https://community.servicenow.com/community?id=community_question&sys_id=b69ba460db3913404e1df4621f9619cb
For each click you client function will be called and you need need server.update() to pass and update the count in your table.