| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
| 3 |
|
| 4 |
function mbt_buybutton_button_add_ga($output, $data, $store) { |
| 5 |
global $post; |
| 6 |
if(!empty($post->post_title)) { |
| 7 |
$ga = 'onclick="if(typeof window._gaq !== \'undefined\'){window._gaq.push([\'_trackEvent\', \'MyBookTable\', \''.$store['name'].' Buy Button Click\', \''.$post->post_title.'\']);}"'; |
| 8 |
$output = preg_replace('/<a/', '<a '.$ga, $output); |
| 9 |
} |
| 10 |
return $output; |
| 11 |
} |
| 12 |
add_filter('mbt_format_buybutton', 'mbt_buybutton_button_add_ga', 10, 3); |
| 13 |
|