Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author paulstuttard

    (@paulstuttard)

    Hi,

    There is no easy way to do this at present, however add the following code fragment to your functions.php might work, I have not tested it:

    function alx_extras_add_link_ga($url){
         $url = str_replace('rel=', 'onClick="_gaq.push([\'_trackEvent\', \'Book\', \'Link\', \'Buy the eBook\']);" rel=', $url);
         return $url;
      }
      add_filter( 'amazon_link_template_get_link_open',  'alx_extras_add_link_class', 22, 1 );
      add_filter( 'amazon_link_template_get_rlink_open', 'alx_extras_add_link_class', 22, 1 );
      add_filter( 'amazon_link_template_get_slink_open', 'alx_extras_add_link_class', 22, 1 );

    Paul

    Plugin Author paulstuttard

    (@paulstuttard)

    Typos in the above, should of course be:

    function alx_extras_add_link_ga($url){
         $url = str_replace('rel=', 'onClick="_gaq.push([\'_trackEvent\', \'Book\', \'Link\', \'Buy the eBook\']);" rel=', $url);
         return $url;
      }
      add_filter( 'amazon_link_template_get_link_open',  'alx_extras_add_link_ga', 22, 1 );
      add_filter( 'amazon_link_template_get_rlink_open', 'alx_extras_add_link_ga', 22, 1 );
      add_filter( 'amazon_link_template_get_slink_open', 'alx_extras_add_link_ga', 22, 1 );

    Paul

    Thread Starter chasman

    (@chasman)

    Okay I’m going to try this as I really need to track all outbound clicks to Amazon within Analytics… I’ve looked into it a bit more and realise the code fragment I gave you isn’t representative of actual use…

    _trackEvent(category, action, opt_label, opt_value, opt_noninteraction)

    category (required)
    The name you supply for the group of objects you want to track.

    action (required)
    A string that is uniquely paired with each category, and commonly used to define the type of user interaction for the web object.

    label (optional)
    An optional string to provide additional dimensions to the event data.

    value (optional)
    An integer that you can use to provide numerical data about the user event.

    non-interaction (optional)
    A boolean that when set to true, indicates that the event hit will not be used in bounce-rate calculation.

    So we need:

    _trackEvent(‘Affil’, ‘Amazon’, $ASIN)

    Where $ASIN is my placeholder for the ASIN of the link they actually clicked…

    Is that doable?

    Plugin Author paulstuttard

    (@paulstuttard)

    Hi,

    Just change the code in the fragment I gave you use %ASIN% to add the product asin, and remember you need to escape the apostrophes.

    function alx_extras_add_link_ga($url){
         $url = str_replace('rel=', 'onClick="_trackEvent(\'Affil\', \'Amazon\', \'%ASIN%\');" rel=', $url);
         return $url;
      }
      add_filter( 'amazon_link_template_get_link_open',  'alx_extras_add_link_ga', 22, 1 );
      add_filter( 'amazon_link_template_get_rlink_open', 'alx_extras_add_link_ga', 22, 1 );
      add_filter( 'amazon_link_template_get_slink_open', 'alx_extras_add_link_ga', 22, 1 );
    Thread Starter chasman

    (@chasman)

    Cool! Cheers 🙂 I’ll get back to you with results…

    Thread Starter chasman

    (@chasman)

    Excellent… Goal Amazon Click is now showing on my GA Dashboard… thanks very much for the help and the excellent plugin.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Google Analytics conversion tracking…’ is closed to new replies.