• Resolved renko

    (@renko)


    Hello Thomas,

    First of all, thank you for the great plugin!

    I have one question regarding the custom thank you pages after woocommerce purchase. I redirect the customer to a custom thank you page not default woocommerce one. And the gtm4.wp.orderCompletedEEC is not present in data layer. Is there any option to include the gtm4.wp.orderCompletedEEC data on the custom thank you page using your plugin?

    If not, which approach do you recommend?

    Thank you and best regards,
    Rene

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Author Thomas Geiger

    (@duracelltomi)

    Hi Rene,

    There is only one option: you need to ensure that your custom order received page acts just like the default page in the background: it should include the same URL parameters (key and order id), it should call the same WordPress/WooCommerce hooks and conditional functions.

    For GTM4WP specifically it is important to hook into the woocommerce_is_order_received_page filter and return “true” on your custom page but all other aspects above should be respected as well.

    Thread Starter renko

    (@renko)

    Hello Thomas,

    Thank you very much for your fast answer.

    My custom thank you page has both parameters, key and order id in URL and also woocommerce_is_order_recieved_page is called on the page, but I still cannot receive the gtm4.wp.orderCompletedEEC data.

    https://prnt.sc/qxk6kh

    Must all WordPress/WooCommerce hooks and conditional functions be present on my page, or the URL parameters and woocommerce_is_order_recieved_page should work?

    Thank you very much and best regards,
    Rene

    Thread Starter renko

    (@renko)

    Hello Thomas (@duracelltomi),

    I investigated the issue a little bit more and print out some data to console from your plugin /integration/woocommerce.php

    I set the output to log right after the 408 line where you get the value of $order_id and $order_key. It turned out that the $order_id variable is 0 on my custom thank you page. I passed the key and order_id as a parameter in URL and the key parameter is read from URL and successfully assigned to $order_key variable, but order_id not. I also attaching the screenshot of my investigation in the link below.

    https://prnt.sc/qyyl6g

    Do you have any idea why this happened?

    Thank you and kind regards,
    Rene

    dominmax

    (@dominmax)

    Hello,
    and is such a construction of url correct (id between slashes):

    checkout/order-recieved/22149/?key=wc_order_4kjh345l3lk

    Regards,
    Dominik

    • This reply was modified 5 years ago by dominmax.
    Thread Starter renko

    (@renko)

    Hello Dominik,

    Thank you for your reply.

    My thank you page URL looks like following:

    https://mydomain.com/thank-you-product1/?key=wc_order_123jdhsh234&order_id=123

    Please see here the url: https://prnt.sc/qyyl6g

    Must the URL be constructed as you posted in your answer? Is it necessary to put the order number between slashes?

    Thank you,
    Rene

    dominmax

    (@dominmax)

    Hello Rene,
    it is my regular url to order-recieved page. I did not change anything. I use Woo 3.8.0.
    I’d rather asked the Plugin Author if my construction will work with the plugin.

    Regards,
    Dominik

    Plugin Author Thomas Geiger

    (@duracelltomi)

    Hi,

    Sorry for the late reply, I was OoO last week.
    GTM4WP reads the order ID from the $wp global using the query_vars[‘order-received’] property and array key. By default, WooCommerce stores the order ID from the URL into this variable.

    GTM4WP also checks for a normal HTTP GET parameter called “order” so if you use this URL:
    https://mydomain.com/thank-you-product1/?key=wc_order_123jdhsh234&order=123
    … it should find the order ID and process the order data.

    Thread Starter renko

    (@renko)

    Hello Thomas,

    Thank you for your answer! Great info I changed the url parameter to order and it works perfectly.

    Thank you for your support and best regards,
    Rene

    Hello @renko

    Been going through this solution but can’t seem to get it right. Any guidance where the URL parameter was changed in the code?

    Thanks

    Thread Starter renko

    (@renko)

    Hi @abstract102,

    You have to build the URL by yourself when you are redirecting the customer to custom TYP and you are free to name the parameter as you want.

    Another hack that I did where you don’t need to change the URL parameter is the following:

    You change the plugin code. In ../plugins/duracelltomi-google-tag-manager/integration/woocommerce.php, find the text:

    $order_id = empty( $_GET[‘order’] ) ? ( $GLOBALS[‘wp’]->query_vars[‘order-received’] ? $GLOBALS[‘wp’]->query_vars[‘order-received’] : 0 ) : absint( $_GET[‘order’] );

    and replace all $_GET[‘order’] with example: $_GET[‘order_id’] or any paramter name you want.

    Keep in mind that this is not the best approach and you have to update this piece of code each time you will update the plugin. But at least it works.

    Hope that this will help you.

    Have a nice day,
    Rene

    @renko Much appreciated. Going to give both solutions a try

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Data layer on Woocommerce custom thank you pages’ is closed to new replies.