cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Help us improve the PTC Community by taking this short Community Survey! X

Trace Visitor visits and its duration on certain Mashup

nikkolasep
12-Amethyst

Trace Visitor visits and its duration on certain Mashup

Hi everyone,

I want to create a dashboard that shows the statistic of unique visitors visit and the duration of it on certain Mashup. Do you have any idea to implement this? 


What I have in mind is:
> Creating a database that records the visitors name and current time and everytime a mashup is opened

> And also record the current time when a mashup is closed (which I'm not so sure whether this is possible or not)


Anyway feel free to give me your idea! I'm looking forward to your ideas!

 

 

ACCEPTED SOLUTION

Accepted Solutions

Eventually I developed a simple javascript function that every xx seconds will call a Thingworx service via REST API Call and this includes all information I want to transmit to my sql database. I wrap this function to a extension and upload/import it to my thingworx server, so that every time a mashup is opened this js function will be called and running in the backgrounds. I additionally uses a user session so that every opened tab will be handled uniquely. To count up the duration of usage I just update my sql database by incrementing the same session id by xx seconds and it works a I expected

View solution in original post

6 REPLIES 6
jensc
17-Peridot
(To:nikkolasep)

Hello,

 

I think your use case sounds interesting so I've been trying to find a way to see when a mashup has been closed.

But unfortunately I haven't been able to find it.

 

I did find some similar posts so perhaps you can find some inspiration from them:

https://community.ptc.com/t5/ThingWorx-Developers/How-to-monitor-users-time-spent-on-thingworx/td-p/728352

https://www.ptc.com/en/support/article/CS288073 

But I don't think they really fully work for you.

 

Looking forward to see if anyone else has any ideas.

 

Regards,

Jens

I never did such a thing, therefore just some brainstorming ideas:

  • Include some 3rd party tracking-library .js in your mashups (I guess via a custom widget you could include it). If all mashups use a Master mashup maybe you could include it in the master. If the library would track the url (which contains the mashup) maybe that  would work.. 
    • I cannot recommend any library here
  • With TWX functionality: In the Master mashup call a custom service e.g. every minute passing the current url as a parameter. If you log those calls (e.g. into a Stream) with (user, time, mashupname) you could create some mechanism which calculates the duration (with accuracy of the interval).
    • e.g. nmutter_0-1685706243434.png

       

    • Where the expression would do someting like
      • Output = location.href;
      • or with newer twx version Output = TW.location.href;
    • But this would only work if the mashups you want to track are actually in the URL (which is not the case with e.g. nested menu navigation). Otherwise you would need to do this logic in each mashup itself, passing its own name to the service..

 

I created similar functionality for the old Widget CSS configurator, which shows the count of mashup reads. In my case, if the user loads up a Mashup, it will log an entry like this: "DateTime,MashupName".

I can extent this to the service execution count - just add a row "DateTime,ServiceName" (just make sure you don't record services triggered by AutoRefresh as well).

I don't care that much how many times they spend on the mashup in my case, because users might simply leave the mashup open, which would result in dirty metrics.

Functionality to collect Mashup usage statistics in ThingWorx Platform PTC article regarding this feature -> "reported as enhancement"

https://www.ptc.com/en/support/article/CS266487

This article introduce how to trace login/logout history where you can calculate the statistic of unique visitors visit then display on mashup.

Eventually I developed a simple javascript function that every xx seconds will call a Thingworx service via REST API Call and this includes all information I want to transmit to my sql database. I wrap this function to a extension and upload/import it to my thingworx server, so that every time a mashup is opened this js function will be called and running in the backgrounds. I additionally uses a user session so that every opened tab will be handled uniquely. To count up the duration of usage I just update my sql database by incrementing the same session id by xx seconds and it works a I expected

Announcements


Top Tags