Support » Plugin: Google Tag Manager for WordPress » Trying to Track Down Cause of Duplicate Conversions

  • dohman

    (@dohman)


    I installed your gtm4wp plugin for a website this past Friday to use with GTM in search of more accurate Analytics data without duplicate conversions appearing. I saw you have built in some functionality for that and believe I have it configured correct.

    Over the weekend we experienced 3 out of 10 transactions that still had conversion revenue doubled up. The exit page pageviews for the these order-received pages also showed these as twice viewed.

    These 3 orders were placed on mobile devices.

    Is it possible this plugin by WooCommerce which modifies our order numbers, (WooCommerce Sequential Order Numbers Pro) could affect the transaction ID that is being checked against for duplilcates? https://docs.woocommerce.com/document/sequential-order-numbers/

    Any other ideas? The website with this issue is beveragelements.com

    Thank you,
    Chris

    —————- Here is gtm4wp view-source of original order-received page—————————-

    <!– Google Tag Manager for WordPress by gtm4wp.com –>
    <script data-cfasync=”false” data-pagespeed-no-defer type=”text/javascript”>//<![CDATA[
    var google_tag_params = {“pagePostType”:”page”,”pagePostType2″:”single-page”,”pagePostAuthor”:”Beverage Elements”,”browserName”:”Chrome”,”browserVersion”:”76.0.3809.132″,”browserEngineName”:”Blink”,”browserEngineVersion”:””,”osName”:”Windows”,”osVersion”:”10.0″,”deviceType”:”desktop”,”deviceManufacturer”:””,”deviceModel”:””,”customerTotalOrders”:0,”customerTotalOrderValue”:”0.00″,”customerFirstName”:””,”customerLastName”:””,”customerBillingFirstName”:””,”customerBillingLastName”:””,”customerBillingCompany”:””,”customerBillingAddress1″:””,”customerBillingAddress2″:””,”customerBillingCity”:””,”customerBillingPostcode”:””,”customerBillingCountry”:””,”customerBillingEmail”:””,”customerBillingPhone”:””,”customerShippingFirstName”:””,”customerShippingLastName”:””,”customerShippingCompany”:””,”customerShippingAddress1″:””,”customerShippingAddress2″:””,”customerShippingCity”:””,”customerShippingPostcode”:””,”customerShippingCountry”:””,”cartContent”:{“totals”:{“applied_coupons”:[],”discount_total”:0,”subtotal”:0,”total”:0},”items”:[]},”ecommerce”:{“currencyCode”:”USD”,”purchase”:{“actionField”:{“id”:”19272″,”affiliation”:””,”revenue”:7.5,”tax”:0.51,”shipping”:4.39,”coupon”:””},”products”:[{“id”:489,”name”:”CO2 Tank Leak Stopper Permanent O-Ring”,”sku”:”CO2LEAKSTOPPER”,”category”:”Cylinder Parts and Accessories”,”price”:2.59,”currency”:”USD”,”stocklevel”:460,”quantity”:1}]}},”event”:”gtm4wp.orderCompletedEEC”,”ecomm_prodid”:[489],”ecomm_pagetype”:”purchase”,”ecomm_totalvalue”:2.59};
    var dataLayer_content = {“visitorType”:”visitor-logged-out”,”visitorIP”:”24.230.147.50″,”pagePostType”:”page”,”pagePostType2″:”single-page”,”pagePostAuthor”:”Beverage Elements”,”browserName”:”Chrome”,”browserVersion”:”76.0.3809.132″,”browserEngineName”:”Blink”,”browserEngineVersion”:””,”osName”:”Windows”,”osVersion”:”10.0″,”deviceType”:”desktop”,”deviceManufacturer”:””,”deviceModel”:””,”customerTotalOrders”:0,”customerTotalOrderValue”:”0.00″,”customerFirstName”:””,”customerLastName”:””,”customerBillingFirstName”:””,”customerBillingLastName”:””,”customerBillingCompany”:””,”customerBillingAddress1″:””,”customerBillingAddress2″:””,”customerBillingCity”:””,”customerBillingPostcode”:””,”customerBillingCountry”:””,”customerBillingEmail”:””,”customerBillingPhone”:””,”customerShippingFirstName”:””,”customerShippingLastName”:””,”customerShippingCompany”:””,”customerShippingAddress1″:””,”customerShippingAddress2″:””,”customerShippingCity”:””,”customerShippingPostcode”:””,”customerShippingCountry”:””,”cartContent”:{“totals”:{“applied_coupons”:[],”discount_total”:0,”subtotal”:0,”total”:0},”items”:[]},”ecommerce”:{“currencyCode”:”USD”,”purchase”:{“actionField”:{“id”:”19272″,”affiliation”:””,”revenue”:7.5,”tax”:0.51,”shipping”:4.39,”coupon”:””},”products”:[{“id”:489,”name”:”CO2 Tank Leak Stopper Permanent O-Ring”,”sku”:”CO2LEAKSTOPPER”,”category”:”Cylinder Parts and Accessories”,”price”:2.59,”currency”:”USD”,”stocklevel”:460,”quantity”:1}]}},”event”:”gtm4wp.orderCompletedEEC”,”ecomm_prodid”:[489],”ecomm_pagetype”:”purchase”,”ecomm_totalvalue”:2.59,”google_tag_params”:window.google_tag_params};
    // if dataLayer contains ecommerce purchase data, check whether it has been already tracked
    if ( dataLayer_content.transactionId || ( dataLayer_content.ecommerce && dataLayer_content.ecommerce.purchase ) ) {
    // read order id already tracked from cookies
    var gtm4wp_orderid_tracked = “”;
    var gtm4wp_cookie = “; ” + document.cookie;
    var gtm4wp_cookie_parts = gtm4wp_cookie.split( “; gtm4wp_orderid_tracked=” );
    if ( gtm4wp_cookie_parts.length == 2 ) {
    gtm4wp_orderid_tracked = gtm4wp_cookie_parts.pop().split(“;”).shift();
    }

    // check enhanced ecommerce
    if ( dataLayer_content.ecommerce && dataLayer_content.ecommerce.purchase ) {
    if ( gtm4wp_orderid_tracked && ( dataLayer_content.ecommerce.purchase.actionField.id == gtm4wp_orderid_tracked ) ) {
    delete dataLayer_content.ecommerce.purchase;
    } else {
    gtm4wp_orderid_tracked = dataLayer_content.ecommerce.purchase.actionField.id;
    }
    }

    // check standard ecommerce
    if ( dataLayer_content.transactionId ) {
    if ( gtm4wp_orderid_tracked && ( dataLayer_content.transactionId == gtm4wp_orderid_tracked ) ) {
    delete dataLayer_content.transactionId;
    delete dataLayer_content.transactionDate;
    delete dataLayer_content.transactionType;
    delete dataLayer_content.transactionAffiliation;
    delete dataLayer_content.transactionTotal;
    delete dataLayer_content.transactionShipping;
    delete dataLayer_content.transactionTax;
    delete dataLayer_content.transactionPaymentType;
    delete dataLayer_content.transactionCurrency;
    delete dataLayer_content.transactionShippingMethod;
    delete dataLayer_content.transactionPromoCode;
    delete dataLayer_content.transactionProducts;
    } else {
    gtm4wp_orderid_tracked = dataLayer_content.transactionId;
    }
    }

    if ( gtm4wp_orderid_tracked ) {
    var gtm4wp_orderid_cookie_expire = new Date();
    gtm4wp_orderid_cookie_expire.setTime( gtm4wp_orderid_cookie_expire.getTime() + (365*24*60*60*1000) );
    var gtm4wp_orderid_cookie_expires = “expires=”+ gtm4wp_orderid_cookie_expire.toUTCString();
    document.cookie = “gtm4wp_orderid_tracked=” + gtm4wp_orderid_tracked + “;” + gtm4wp_orderid_cookie_expire + “;path=/”;
    }

    }
    dataLayer.push( dataLayer_content );//]]>
    </script>
    <script data-cfasync=”false”>//<![CDATA[
    (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({‘gtm.start’:
    new Date().getTime(),event:’gtm.js’});var f=d.getElementsByTagName(s)[0],
    j=d.createElement(s),dl=l!=’dataLayer’?’&l=’+l:”;j.async=true;j.src=
    ‘//www.googletagmanager.com/gtm.’+’js?id=’+i+dl;f.parentNode.insertBefore(j,f);
    })(window,document,’script’,’dataLayer’,’GTM-W29H59F’);//]]>
    </script>
    <!– End Google Tag Manager –>
    <!– End Google Tag Manager for WordPress by gtm4wp.com –>

    ———— here is view-source of when I reloaded the order-received page in a new tab ———————–

    <!– Google Tag Manager for WordPress by gtm4wp.com –>
    <script data-cfasync=”false” data-pagespeed-no-defer type=”text/javascript”>//<![CDATA[
    var google_tag_params = {“pagePostType”:”page”,”pagePostType2″:”single-page”,”pagePostAuthor”:”Beverage Elements”,”browserName”:”Chrome”,”browserVersion”:”76.0.3809.132″,”browserEngineName”:”Blink”,”browserEngineVersion”:””,”osName”:”Windows”,”osVersion”:”10.0″,”deviceType”:”desktop”,”deviceManufacturer”:””,”deviceModel”:””,”customerTotalOrders”:0,”customerTotalOrderValue”:”0.00″,”customerFirstName”:””,”customerLastName”:””,”customerBillingFirstName”:””,”customerBillingLastName”:””,”customerBillingCompany”:””,”customerBillingAddress1″:””,”customerBillingAddress2″:””,”customerBillingCity”:””,”customerBillingPostcode”:””,”customerBillingCountry”:””,”customerBillingEmail”:””,”customerBillingPhone”:””,”customerShippingFirstName”:””,”customerShippingLastName”:””,”customerShippingCompany”:””,”customerShippingAddress1″:””,”customerShippingAddress2″:””,”customerShippingCity”:””,”customerShippingPostcode”:””,”customerShippingCountry”:””,”cartContent”:{“totals”:{“applied_coupons”:[],”discount_total”:0,”subtotal”:0,”total”:0},”items”:[]}};
    var dataLayer_content = {“visitorType”:”visitor-logged-out”,”visitorIP”:”24.230.147.50″,”pagePostType”:”page”,”pagePostType2″:”single-page”,”pagePostAuthor”:”Beverage Elements”,”browserName”:”Chrome”,”browserVersion”:”76.0.3809.132″,”browserEngineName”:”Blink”,”browserEngineVersion”:””,”osName”:”Windows”,”osVersion”:”10.0″,”deviceType”:”desktop”,”deviceManufacturer”:””,”deviceModel”:””,”customerTotalOrders”:0,”customerTotalOrderValue”:”0.00″,”customerFirstName”:””,”customerLastName”:””,”customerBillingFirstName”:””,”customerBillingLastName”:””,”customerBillingCompany”:””,”customerBillingAddress1″:””,”customerBillingAddress2″:””,”customerBillingCity”:””,”customerBillingPostcode”:””,”customerBillingCountry”:””,”customerBillingEmail”:””,”customerBillingPhone”:””,”customerShippingFirstName”:””,”customerShippingLastName”:””,”customerShippingCompany”:””,”customerShippingAddress1″:””,”customerShippingAddress2″:””,”customerShippingCity”:””,”customerShippingPostcode”:””,”customerShippingCountry”:””,”cartContent”:{“totals”:{“applied_coupons”:[],”discount_total”:0,”subtotal”:0,”total”:0},”items”:[]},”google_tag_params”:window.google_tag_params};
    // if dataLayer contains ecommerce purchase data, check whether it has been already tracked
    if ( dataLayer_content.transactionId || ( dataLayer_content.ecommerce && dataLayer_content.ecommerce.purchase ) ) {
    // read order id already tracked from cookies
    var gtm4wp_orderid_tracked = “”;
    var gtm4wp_cookie = “; ” + document.cookie;
    var gtm4wp_cookie_parts = gtm4wp_cookie.split( “; gtm4wp_orderid_tracked=” );
    if ( gtm4wp_cookie_parts.length == 2 ) {
    gtm4wp_orderid_tracked = gtm4wp_cookie_parts.pop().split(“;”).shift();
    }

    // check enhanced ecommerce
    if ( dataLayer_content.ecommerce && dataLayer_content.ecommerce.purchase ) {
    if ( gtm4wp_orderid_tracked && ( dataLayer_content.ecommerce.purchase.actionField.id == gtm4wp_orderid_tracked ) ) {
    delete dataLayer_content.ecommerce.purchase;
    } else {
    gtm4wp_orderid_tracked = dataLayer_content.ecommerce.purchase.actionField.id;
    }
    }

    // check standard ecommerce
    if ( dataLayer_content.transactionId ) {
    if ( gtm4wp_orderid_tracked && ( dataLayer_content.transactionId == gtm4wp_orderid_tracked ) ) {
    delete dataLayer_content.transactionId;
    delete dataLayer_content.transactionDate;
    delete dataLayer_content.transactionType;
    delete dataLayer_content.transactionAffiliation;
    delete dataLayer_content.transactionTotal;
    delete dataLayer_content.transactionShipping;
    delete dataLayer_content.transactionTax;
    delete dataLayer_content.transactionPaymentType;
    delete dataLayer_content.transactionCurrency;
    delete dataLayer_content.transactionShippingMethod;
    delete dataLayer_content.transactionPromoCode;
    delete dataLayer_content.transactionProducts;
    } else {
    gtm4wp_orderid_tracked = dataLayer_content.transactionId;
    }
    }

    if ( gtm4wp_orderid_tracked ) {
    var gtm4wp_orderid_cookie_expire = new Date();
    gtm4wp_orderid_cookie_expire.setTime( gtm4wp_orderid_cookie_expire.getTime() + (365*24*60*60*1000) );
    var gtm4wp_orderid_cookie_expires = “expires=”+ gtm4wp_orderid_cookie_expire.toUTCString();
    document.cookie = “gtm4wp_orderid_tracked=” + gtm4wp_orderid_tracked + “;” + gtm4wp_orderid_cookie_expire + “;path=/”;
    }

    }
    dataLayer.push( dataLayer_content );//]]>
    </script>
    <script data-cfasync=”false”>//<![CDATA[
    (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({‘gtm.start’:
    new Date().getTime(),event:’gtm.js’});var f=d.getElementsByTagName(s)[0],
    j=d.createElement(s),dl=l!=’dataLayer’?’&l=’+l:”;j.async=true;j.src=
    ‘//www.googletagmanager.com/gtm.’+’js?id=’+i+dl;f.parentNode.insertBefore(j,f);
    })(window,document,’script’,’dataLayer’,’GTM-W29H59F’);//]]>
    </script>
    <!– End Google Tag Manager –>
    <!– End Google Tag Manager for WordPress by gtm4wp.com –>

Viewing 15 replies - 16 through 30 (of 30 total)
  • Plugin Author Thomas Geiger

    (@duracelltomi)

    Hi Chris,

    Almost 🙂
    There is a second beta available on github:
    https://github.com/duracelltomi/gtm4wp/releases

    With that, in Chrome, you will find the “cookie” stored in the Local Storage part of the page that you captured for me. This should work in more cases even in Safari

    great. i’ll give that a shot this evening and be in touch. thank you!

    here are links to images of local storage and cookies. i would appreciate any insight you can provide on this and the recent changes.

    https://werpo.net/wp-content/uploads/2019/11/20191106-799-local-storage.jpg
    https://werpo.net/wp-content/uploads/2019/11/20191106-799-cookies.jpg

    thanks much, thomas!

    Plugin Author Thomas Geiger

    (@duracelltomi)

    Great, this is how it should work. The gtm4wp prefixed local storage item will prevent re-executing ecommerce tracking in your mobile browser

    is beta 2 the first version that is using this local storage method?

    I tried beta 2 and could not recreate a duplicate transaction with it. I then tried it again running beta 1 and the current 1.10.1 release but could not recreate a duplicate with those either. up until then I could recreate the duplicate pretty much any time. so I am a bit confused. could something remain from beta 2 that is still preventing a duplicate when I test with the old versions?

    thanks,
    chris

    Plugin Author Thomas Geiger

    (@duracelltomi)

    V1.10.1 has used wrong cookie parameters, local storage usage was introduced with v1.11beta1 and included some fix with beta2

    Since for an existing order there is a well stored browser data, tracking prevention works fine in prior plugin versions

    So, if I ran a test order with the betas, then reverted back to the prior release and ran more test orders, the duplicates would still be prevented using the prior release plugin? Sorry, I don’t quite understand how that works. If you have any more insight to that, that would be great.

    When do you plan to release the next version which includes the 2 betas? Do you think the betas ready for a live ecommerce site?

    thanks,
    chris

    Plugin Author Thomas Geiger

    (@duracelltomi)

    Hi Chris,

    There were two issues:
    – v1.10.x used a wrong cookie name while setting the prevention cookie
    – Safari was blocking this cookie anyway so I had to change this to a local storage object

    Depending on the order of plugin version usage v1.11 betas set the proper cookie and/or the local storage object.

    In v1.10.x reading the cookie was correct, setting it had an issue. So if 1.11beta set the cookie then v1.10 was able to read it.

    Everything above applies for the same order. So if you reverted back to v1.10 and placed a new order, that should still have double tracking issues.

    Does this make things more clear?

    Yes, thanks for the clarification.

    I did revert back to 1.10.1, placed new orders, but could not replicate the duplicates. I am going to make sure the old files are indeed being used, then do some additional tests to see if I can prove out my issues are solved.

    How do you feel about the beta 2? Do you think is it to a point it can be used on a live site?

    Thanks again for all your help and work maintaining and improving the plugin!
    chris

    Plugin Author Thomas Geiger

    (@duracelltomi)

    Some fixes has been added since then this week, the final v1.11 is going to be released next Monday.

    sounds great. will wait for that one. thanks again, thomas!

    I’ve updated to 1.11.1 but I’m still getting duplicate conversions when I open my browser back up to the thank you page..

    Here are screen grabs of the local, session & cookies:
    https://werpo.net/wp-content/uploads/2019/11/20191112-cookies.jpg
    https://werpo.net/wp-content/uploads/2019/11/20191112-session-storage.jpg
    https://werpo.net/wp-content/uploads/2019/11/20191112-local-storage.jpg

    I see a js error and cookie warnings which you can see in the cookies image. Is there any way could be creating an issue?

    We are also running the Google Customer Reviews for WooCommerce plugin which displays a pop-up on the thank you page. Could this be interfering?

    thanks,
    chris

    thanks,
    chris

    Plugin Author Thomas Geiger

    (@duracelltomi)

    Hi Chris,

    I opened the order received page on your screenshot and I do not see ecommerce data in the data layer and therefore no transactions are being recorded.

    There is a gtm4wp related item in your local storage screenshot which should prevent duplicate transactions on mobile devices.

    So when you say “and therefore no transactions are being recorded.” are you saying no duplicate transaction is being recorded?

    I am seeing conversions/transaction in GA, and a duplicate when I open my browser back up having never closed the thank you tab. It does not record a duplicate when the page is refreshed which would be what you did there by entering the url.

    Could there be anything else with the tag configuration or conflicting plugin like the google review pop-up on the thank you page?

    thanks,
    chris

    Plugin Author Thomas Geiger

    (@duracelltomi)

    Yes, I checked network requests on the specific order received page and it did not include and ecommerce purchase data.

    The local storage object should prevent duplicate tracking in your cases, it is hard to tell why it is not working in your browser 🙁

Viewing 15 replies - 16 through 30 (of 30 total)
  • You must be logged in to reply to this topic.