Posted: June 1, 2020 at 8:51 pm
I was reading this post and it’s awesome https://eventespresso.com/topic/push-conversion-event-to-datalayer/ But how can I make the price dynamically fill on a purchase conversion? Would the code Josh placed on that post listed above be able to append the code from this facebook post? https://www.facebook.com/business/help/262326191335941 Basically I want the purchase event to fire and tell Facebook the total price of the cart AND/OR the total of the items bought. But if only one way would work, the total value of the cart on Event Espresso would be great to send with the FB Purchase Pixel Event firing on Google Tag Manager. |
|
Hi Jarred, The hook used with that snippet is passed the https://github.com/eventespresso/event-espresso-core/tree/master/docs/G–Model-System
When you say ‘items bought’ do you just need the number of tickets selected in total? |
|
I have a Custom HTML container and using the code Josh gave me I can see value now for the ticket price. But how can I implement the PHP that you mentioned for Transaction Total? Basically i just need the transaction total to be sent with the Purchase fired tag so fb has a value of the conversion. I have this now: /////////////////// and for my fb script I have vale has dlv-transactionTotal because I made it a data layer variable for transactionTotal. What PHP do I need to pull the Event espresso Transaction total? Shows this data layer after message |
|
I was able to fire the correct trigger for GTM using the code from Josh’s old post by using a “Custom Event” as the trigger instead of pageview. http://prntscr.com/ssrx97 If curious where I got the {{Espresso Value}} seen in image, its a user-defined data layer variable I created to pull in the value (total cost) of event espresso thank you page. SO it give full total. http://prntscr.com/ssrzcn ===================================== Now I’m trying to do Google Analytics event and have the sales show up on the Enhanced Ecommerce sale report. I was able to get the Event to fire on google analytics BUT, it wont pull in the value for some reason. Is there a way to have Event Espresso Transaction ID and a way to have the Event Name (name of the class or camp they bought) in the data layer so I can include it with ‘eventRegistration’ ? I don’t know the PHP language but I think what I’m asking is this: include the following items with ‘eventRegistration’ in the data layer so that when I call on eventRegistration to trigger a tag firing it will include these items. Currency: (already have by writing manually) Thanks |
|
In Josh’s example, you have the EE_Transaction object within I’m assuming you already know JavaScript so you know how to add additional values to the dataLayer, correct? So I can show you how to pull the values you are requesting, but some some aren’t as clean cut as they seem.
You don’t need to hardcode the currency, you can pull it from the EE_Registry:
So, something like:
You already have this, but imo, ‘value’ is a misleading variable name here. I’d recommend changing it to something like ‘transactionTotal’. Reason being in x months when you view this code back and think ‘Value? Value of what?’ it’s not obvious without going through the code, ‘transactionTotal’ is.
Event Name isn’t as simple here because a transaction can be have multiple registrations within them and if using the Multi Event Registration Add-on any/each/all of those registrations could be for different events. The simplest way to pull a single event name is to use the ‘Primary Registration’ and pull the details/event linked to that. So at the top of Josh’s function add something like:
Then in the JavaScript you can use ‘eventName’ : ‘<?php echo $event_name; ?>’
You already have the transaction object, so
Date? Today’s date? Transaction date? (They may not match depend on what you are doing so you need to be specific here) Transaction date can be pulled in using Is that what you are looking for? (Note all of the above is untested and hand written) |
|
The support post ‘Google Tag Manager Dynamic Price for Purchase Event’ 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.