Support

Home Forums Event Espresso Premium Modify add to cart confirmation popup

Modify add to cart confirmation popup

Posted: August 9, 2015 at 3:37 am

Viewing 5 reply threads


Marcus

August 9, 2015 at 3:37 am

I need to add a conversion pixel when something is added to the cart, so I figure I need to hook into the content of the confirmation popup: http://grab.mogmachine.com/JsTG

Does anyone know the hook to do this please.


Dean

August 10, 2015 at 4:08 am

Hi,

There are no action hooks, but you could use the filter hook FHEE__EED_Multi_Event_Registration__get_cart_results_current_cart_message and apply the image to the message.

Filter hook found in /wp-content/plugins/eea-multi-event-registration/EED_Multi_Event_Registration.module.php


Marcus

August 11, 2015 at 3:08 am

Hi Dean,

I have tried this:

function ee_add_cart_popup_tracking_pixel() {
	$tracking =" <!-- Facebook Conversion Code for Add to Basket - Soundwave -->
	<script>(function() {
	var _fbq = window._fbq || (window._fbq = []);
	if (!_fbq.loaded) {
	var fbds = document.createElement('script');
	fbds.async = true;
	fbds.src = '//connect.facebook.net/en_US/fbds.js';
	var s = document.getElementsByTagName('script')[0];
	s.parentNode.insertBefore(fbds, s);
	_fbq.loaded = true;
	}
	})();
	window._fbq = window._fbq || [];
	window._fbq.push(['track', '6027949875958', {'value':'0.00','currency':'USD'}]);
	</script>
	<noscript><img height=\"1\" width=\"1\" alt=\"\" style=\"display:none\" src=\"https://www.facebook.com/tr?ev=6027949875958&cd[value]=0.00&cd[currency]=USD&noscript=1\" /></noscript>";
 echo $tracking;
}
add_filter ('FHEE__EED_Multi_Event_Registration__get_cart_results_current_cart_message', 'ee_add_cart_popup_tracking_pixel');

But it just breaks the overlay completely, ..and I am not 100% sure it is the right thing to do.


Dean

August 11, 2015 at 4:55 am

Hmmm yeah, I had it in my head for some reason, that the code you would be adding would be literally a single pixel image.

The scripts etc won’t work via that filter unfortunately.

There’s no other hooks or filters for the modal, but could you perhaps just use the Footer of the page?


Marcus

August 12, 2015 at 3:50 am

I did try to find the code for the popup window to manually paste it in, which I found, ..but then I realised I had no way to check which event the code was being spat out for, and of course I did not want to add the code for all events, ..so am a little stuck now 🙁


Josh

  • Support Staff

August 12, 2015 at 1:59 pm

Hi Marcus,

You’ll likely end up going a different route to add your tracking code, but I can share with you a tip about how to use a WP filter hook to modify existing content.

It turns out when you use a WP filter hook to replace content, you need to return the content instead of echoing it. Along with that, you’re aiming to add to the existing content and not replace it entirely.

So here’s an example of how you can use the filter hook that Dean suggested to add your facebook tracking code to the content that normally gets returned:

function ee_add_cart_popup_tracking_pixel( $message, $total_tickets ) {
		$tracking = "";
		$message .= $tracking; 	// append tracking code to original message
	return $message;
}

add_filter ('FHEE__EED_Multi_Event_Registration__get_cart_results_current_cart_message', 'ee_add_cart_popup_tracking_pixel', 10, 2);

Since you mention that you need to only output the tracking code for specific events and not all events, I can advise taking a different approach where you conditionally output the tracking code on the registration-checkout page after the event is added to the cart. This way you’ll have access to the event object via the current session’s checkout.

Viewing 5 reply threads

The support post ‘Modify add to cart confirmation popup’ 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