web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Service | Customer Service, Contact Center, Fie...
Suggested Answer

How can create a log (counter) page within CRM for every TAB that is clicked by a user (TAB tracking..)

(0) ShareShare
ReportReport
Posted on by 5

I want to track how often certain TABS are clicked by users within CRM365. 

So let's say on the Account form there is a TAB called 'Adress' I want to know how often users click on that TAB.

It is not necessary to know which user has clicked how many times on that TAB but just how many times that TAB is clicked on by all users.

I was thinking on setting up an Entity called 'TAB logging'

And then have whole number fields like : 'Account_Adress' , 'Account_History' , 'Account_Information' , corresponding to the name of the TABS within t he account form.

Every time a TAB is openend / clicked on by a user then the number in e.g. field  'Account_Adress'  on entity 'TAB logging' is +1 higher.

I found a Jscript (carldesouza.com/run-javascript-when-user-clicks-on-unified-interface-tab/)  that responds to a user click on a TAB only now it shows an alert (that I don't want).

-----------------------------------------------------------------------------------

function OnLoad(executionContext) {
formContext = executionContext.getFormContext();

var PartnerDetailsTab = formContext.ui.tabs.get("Partner_Details");
PartnerDetailsTab.addTabStateChange(TabClicked);
}

function TabClicked() {
alert("Tab Clicked");
}

-------------------------------------------------------------------------------------

It would be great if somebody has a Jscript for this wish (or another solution).

The purpose of this TAB logging is to know how often a TAB is clicked on by users so that we can decide whether we want to invest more on certain data that is showed in that TAB or that we can remove the TAB because it is not used often enough.

Actually I think it's kind of weird that I cannot find anything on this kind of functionality.  

To be sure: I know there is Auditing in System Settings but that is not what I mean, also not the 'Start read auditing'  option which is way to intrusive. 

  • Suggested answer
    Community Member Profile Picture
    on at

    Try something like this, I'm sure there is a slightly more efficient way to write this, but I had something kind of written up already that I just updated.  Let me know if you get stuck, most of the ALLCAPS stuff is where you need to replace with schema.

    function OnLoad(executionContext) {

    formContext = executionContext.getFormContext();

    var PartnerDetailsTab = formContext.ui.tabs.get("Partner_Details");

    PartnerDetailsTab.addTabStateChange(TabClicked);

    }

    function TabClicked(executionContext) {

    formContext = executionContext.getFormContext();

    var recordtoUpdatesGUID = DEPENDSHOWYOUAREPASSINGINTHEID;

    if(recordtoUpdatesGUID)

    {

    var guidOfNewTable = recordtoUpdatesGUID[0].id.slice(1, -1);

    Xrm.WebApi.retrieveRecord("SCHEMANAMEOFNEWTABLE", guidOfNewTable, "?$select=INTFIELDSCHEMANAME").then(

    function success(result){

    var currentCount = result.INTFIELDSCHEMANAME;

    var newCountFieldValue = currentCount + 1;

    var data =

    {

    "INTFIELDSCHEMANAME": newCountFieldValue

    }

    Xrm.WebApi.updateRecord("SCHEMANAMEOFNEWTABLE", guidOfNewTable, data).then(

    function success(result) {

    console.log("record updated");

    },

    function (error) {

    console.log(error.message);

    // handle error conditions

    }

    );

    },

    function (error) {

    //failed to find the record to update

    console.log(error.message);

    }

    );

    }

    }

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Service | Customer Service, Contact Center, Field Service, Guides

#1
Daniyal Khaleel Profile Picture

Daniyal Khaleel 58 Most Valuable Professional

#2
Travis South Profile Picture

Travis South 37

#3
ParthPatel249 Profile Picture

ParthPatel249 19

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans