Posted: July 8, 2019 at 5:13 pm
|
Hi there I’m working to push some conversion data into the datalayer that I think would be very helpful to all those that use Google Tag Manager so they can fire events for conversions to various tracking platforms (LinkedIn Insights, Google Analytics, Facebook Pixel. Here is the datalayer code I want to fire:
Could you possibly show me the PHP I could use in the functions.php to handle this? Thanks, |
Hi, May I ask what’s the value “120” coming from? I want to make sure I point you in the right direction in case that’s a value coming from the transaction or event that’s being registered for. Also, is there any other context for this code you want to add? |
|
|
Yes the 120 would be the dollar value (without the $) from the total cost of the registration. There are lots of others that would be very useful (an array of the event ids they registered for, event name, the transaction id, registration code, number of tickets purchased, event categories) There are probably more that would be very useful for those that want to implement E-commerce or Enhanced E-commerce reporting for Google Analytics as well but I haven’t thought through that as of yet. Also pushing other events into the data layer for when users move through the checkout steps would be very useful as well. Thanks, |
Hi, I’ll assume this is something you want to add to the thank-you page, if that’s true, then the following PHP could be started with:
Anything else transaction, event, and registration-related you’d like to add can be grabbed from the $transaction object by using the model system which is documented here: https://github.com/eventespresso/event-espresso-core/tree/master/docs/G–Model-System |
|
|
Would this fire every time someone reloaded the Thank You page though? |
It would as is. You could make it a one time thing by setting a token on the session after the push, then check for that token e.g.
|
|
|
Awesome! Thanks Josh. I will implement that code and see how it goes. |
The support post ‘Push Conversion Event to DataLayer’ 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.