add action when any page of my site is displayed to the end user

I want to track the pages visited on my WP site, whether the user is connected or not.
I need to track this information in a proprietary database.
I am using a child theme. How can I do this? Which WP action or hook should I use?
I have been through the WP Codex and Google, but could not find a clear answer to that.

  • Sajid

    Hi Luce Tancil,
    Hope you are doing good today :slight_smile:

    You can use either wp_footer or wp_header action hooks as well as init. If you go with init then you can check if the user is not in admin area then with !is_admin conditional tag.

    For post/pages visits you can store the data in wp_postmeta table by using the update_post_meta function.

    You would also want to check if its a unique visit or not by tracking the IP address.

    Hope that helps! Feel free to post a reply if you need further assistance :slight_smile:

    Best Regards,
    Sajid

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.