Create a link that calls our custom function in WordPress

Try this

add_action( 'wp_loaded','data_collection');

function data_collection(){
   if ( $_SERVER[REQUEST_URI] == '/mypage' ) {
   //my coding stuff
   }
}