Support

Home Forums Event Espresso Premium Affiliate tracking code – which page?

Affiliate tracking code – which page?

Posted: January 18, 2013 at 1:34 pm


Jess Nunez

January 18, 2013 at 1:34 pm

We’re setting up tracking for affiliates, but I’m not sure which page to track. We tried setting it to the [ESPRESSO_PAYMENTS] page but that’s not tracking well. Should we put it in the page with [ESPRESSO_TXN_PAGE]?


Josh

  • Support Staff

January 18, 2013 at 2:11 pm

Hi Jess,

I’m imagining that you would only want to run the affiliate tracking code if the payment is complete, is that correct? If so, I would suggest adding the affiliate tracking code in return_payment.php, which is a template file that can be copied over to /wp-content/uploads/espresso/templates so that it doesn’t get overwritten on an update.

I would try putting the code within the block of code that runs if the payment status is complete, which is right on line 13:

if ($payment_status == "Completed") {
    //echo '<p class="payment_details payment_paid">'.__('Our records indicate you have paid','event_espresso')." ".$org_options['currency_symbol'].$event_cost."</p>";
}

One thing to keep in mind about copying templates over to /wp-content/uploads/espresso/templates. If we change something in a template in a future version, the updated code will need to be copied into the customized template. I usually recommend leaving a reminder note for when you update Event Espresso to check for changes made to the templates that were customized.


Jess Nunez

January 18, 2013 at 2:25 pm

Thank you Josh! Actually we’re just using Google Analytics for tracking, so I have to give it an actual page URL that’s hit when payment is complete. The page with [ESPRESSO_EVENTS] appears to be used multiple times, and you’re right, we only want to track completed payments. Would analytics pick up on the [ESPRESSO_TXN_PAGE] if it’s used by the system?


Josh

  • Support Staff

January 18, 2013 at 3:41 pm

The page with the [ESPRESSO_TXN_PAGE] shortcode isn’t viewed in a browser when someone pays for event registration, so no, analytics will not be able to track it. It’s only used as an IPN listener by a few of the gateways included with Event Espresso.

Usually there’s tracking code that can be placed on a receipt page, at least there is with the Ecommerce tracking feature of Google Analytics. Is there any option to use tracking code?


Jess Nunez

January 19, 2013 at 12:13 am

Ok thank you for explaining that! So in return_payment.php around line 13 I pasted in our analytics code. Google requires certain information to be returned for e-commerce tracking, and I pulled the values for the transaction ID and cost, etc, from the sample given in affiliate_tracking.php. Is that ok?

One other question: we have GA already inserted within the head of all pages. And the code that I put into the template is the full GA code again. Will it still work, even if it might show up more than once to GA? And will it work even though it doesn’t look like it’s going into the head?

Here’s the code that I placed in:

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-xxxxxxx-1']);

  _gaq.push(['_trackPageview']);

   _gaq.push(['_addTrans',

    '',           // transaction ID - required

    'Site Name',  // affiliation or store name

    ''         // total - required
  ]);


   // add item might be called for every item in the shopping cart
   // where your ecommerce engine loops through each item in the cart and
   // prints out _addItem for each

  _gaq.push(['_addItem',

    '',           // transaction ID - required
    '',           // SKU/code - required
    '',          // unit price - required
    '1'               // quantity - required
  ]);
  _gaq.push(['_trackTrans']); //submits transaction to the Analytics servers

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();


Jess Nunez

January 19, 2013 at 12:14 am

Oh I see, my php was removed. Here it is again:

_gaq.push(['_addTrans',
    '',           // transaction ID - required
    'Store name',  // affiliation or store name
    ''         // total - required
  ]);


Jess Nunez

January 19, 2013 at 12:15 am

Nope still not working. I’m so sorry. Anyway I did a php echo $txn_id and $total_cost


Jess Nunez

January 20, 2013 at 6:00 pm

Well it’s not tracking in GA so I moved the new GA code to the main header.php file and ran a test transaction. The variables that need to be displayed in the GA code aren’t showing up, and I’m not sure how to echo them properly. How do I echo the transaction ID in the header.php file? When I view the source of the final transaction page here’s what shows:

     _gaq.push(['_addTrans',
    '',           // transaction ID - required
    'Store Name',  // affiliation or store name
    ''         // total - required
  ]);

   // add item might be called for every item in the shopping cart
   // where your ecommerce engine loops through each item in the cart and
   // prints out _addItem for each
  _gaq.push(['_addItem',
    '',           // transaction ID - required
    '',           // SKU/code - required
    '',          // unit price - required
    '1'               // quantity - required
  ]);
  _gaq.push(['_trackTrans']); //submits transaction to the Analytics servers


Seth Shoultes

  • Support Staff

January 22, 2013 at 12:22 am

Hi Jess,

Maybe this post will help? It is a similar concept:
https://eventespresso.com/topic/wp-affiliate-integration/#post-32167

The support post ‘Affiliate tracking code – which page?’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso