This code
<?php
if(r::ajax()) {
$article->increment('clicks');
}
?>
should be in the template of the page that is called (i.e. probably the article.php
template in your case).
Change $article
to $page
in the new location.