Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Josip 187 posts 652 karma points c-trib
    Mar 12, 2019 @ 12:37
    Josip
    0

    Click counter by clicking the button

    Members on their profiles have collapse button which shows the phone number on click and i would like to count this clicks in the database for each member.

    Later i would like to show them this numbers when they log in in their profiles.

    I found articles which count page visits but i need to count clicks on buttons.

    What would be the best approach?

    Maybe i could create custom table in the databsae and than somehow make relation with members (I never tried it in Umbraco), or i can use Google Analtics maybe?

  • Josip 187 posts 652 karma points c-trib
    Mar 15, 2019 @ 10:42
    Josip
    0

    Any ideas?

  • Frans de Jong 522 posts 1762 karma points c-trib
    Mar 15, 2019 @ 16:04
    Frans de Jong
    0

    What you could do is add a javascript eventhandler on the button click. In that event call a surface controller and store the new number.

    Documentation on surfacecontrollers

  • Josip 187 posts 652 karma points c-trib
    Mar 15, 2019 @ 17:07
    Josip
    0

    In that case i would need to create custom table or there is another way?

  • Paul Seal 428 posts 2354 karma points MVP 3x c-trib
    Mar 15, 2019 @ 16:55
    Paul Seal
    100

    I would use Google Analytics Event tracking for this.

    See this blog post for an easy way to do it.

    https://codeshare.co.uk/blog/how-to-set-up-ga-event-tracking-in-3-easy-steps/

    Also notice the optional attribute data-event-value I would pass the integer id of the member into that. Now you have all of the data you need, using Google Analytics so no need to create database tables or any custom code other than a bit of javascript to send it to GA.

    Cheers

    Paul

  • Josip 187 posts 652 karma points c-trib
    Mar 15, 2019 @ 17:03
    Josip
    0

    Great article i will give it a try, do you think it will be easy to display number of clicks for each member in their frontend member profile?

  • Frans de Jong 522 posts 1762 karma points c-trib
    Mar 19, 2019 @ 08:17
    Frans de Jong
    1

    Looks like it's possible to request tracking data from analytics

    https://developers.google.com/analytics/devguides/reporting/core/v4/quickstart/web-js#2setupthe_sample

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies