How do I trigger an event when a button is clicked on a user profile?
Wow, this is a question with many solutions. Some stuff I can quickly think of:

Developers way:


create a custom module: https://www.drupal.org/developing/modules/7
implement hook_menu to create callbacks for your links
implement your logic in the callback functions defined for your entries in hook_menu.
"presentation layer". Depending on the structure of your website and your profiles:

a) Create a block with your links in it, references: block_example, link function

b) Implement a "pseudo field" on fieldable entities (e.g. user, profile2)

c) Use link function in your profile template file e.g. user-profile.tpl.php


extra points might be awarded if you use the link function and your hook menu implementation together with the ajax framework. example.

Site builders way (one way.. there are many):


create a flag
create a rule for flagging items
in that rule implement your logic
optional: undo the flagging (so the user can do this action again)


All of the mentioned solutions will probably require some logic for handling the access and display of that button as well.

(one) developer way, if this button appears on user/id:

&lt;?php
global $user;    
if (arg(0) == 'user' &amp;&amp; arg(1) == $user-&gt;uid &amp;&amp; null === arg(2) {
  print l('do something', 'yourcallballback/' . arg(1));
}


site builders way (for the example from above):

usually there's no additional access check required here, you can setup that flag to be global and only clickable once if you want to make sure that it's only available once. for the display part you probably really have to use code to only show that flag if the current user visits his own profile.