• Resolved willlweb

    (@willlweb)


    Hi there,

    We use your plugin for our eCommerce store & it works great so thanks for that.

    We want to just send a single custom dimension value for each pageview, which will record if the visitor has subscribed to push notifications of not (this value already exists in a variable).

    I’ve tried multiple things including adding the below to the footer:
    ga(‘send’, ‘pageview’, { ‘dimension1’: ‘Subscribed’ });

    However i either can’t get it to track or it says ga is not defined. My script is deferred so it should be running after your plugin script , at which point i’m guessing ga is defined.

    Would appreciate your help on this.

    Thanks
    Will

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Conversios

    (@tatvic)

    Hi @willlweb,

    Please try adding the following lines of code just after the GA tracking snippet in the head section:

    <?php if ( current_user_can(‘subscriber’) ) : ?>
    echo “<script>
    gtag(‘config’, ‘UA-XXXXXX-X’, { ‘custom_map’: { ‘dimensionX’: ‘Subscribed’
    }});
    </script>”;
    <?php endif; ?>

    Please check the working of it and post us whether you are able to send the custom dimension?

    Regards,
    Tatvic Analytics.

    Thread Starter willlweb

    (@willlweb)

    Hi there,

    Thanks for coming back to me.

    I’ve tried this but i then get an error in Tag Assistant saying that the ‘Same web property ID is tracked twice’, so it’s recording 2 pageviews each time.

    Look forward to hearing from you.

    Thanks

    Plugin Author Conversios

    (@tatvic)

    Hi @willlweb,

    The duplicate tracking seems to be due to the presence of 2 GA tracking snippets on your store.

    Please share the store URL so that we could check and reply to you accordingly.

    Regards.

    Thread Starter willlweb

    (@willlweb)

    Hi there,

    Yes, however the duplicate tracking only shows when i add the gtag snippet that you included above.

    Here is the site link: https://levelfivesupplies.com/ and you should see just the one GA tracking code is firing currently which is fine. But i’m not recording the dimension which is the problem.

    This current setup is with just using your plugin as is, which records the eCommerce data perfectly, we just need to record this extra custom dimension which i can’t see how to do without tracking the pageview twice.

    Thanks

    Thread Starter willlweb

    (@willlweb)

    Hi there,

    Has there been any update on this one?

    Thanks

    Plugin Author Conversios

    (@tatvic)

    Hey @willlweb,

    Sorry for posting you a bit late.

    Please follow the below steps to load the earlier shared script dynamically, so that duplication issue could be avoided:

    1) Copy the below script for custom dimension (Modify the ‘Xs’ in the script):

    <?php if ( current_user_can(‘subscriber’) ) : ?>
    echo “<script>
    gtag(‘config’, ‘UA-XXXXXX-X’, { ‘custom_map’: { ‘dimensionX’: ‘Subscribed’
    }});
    </script>”;
    <?php endif; ?>

    2) Go to the file path: wp-content\plugins\enhanced-e-commerce-for-woocommerce-store\public

    3) Open the file: class-enhanced-ecommerce-google-analytics-public.php

    4) Paste the script for custom dimension below the following lines of code:

    $code = ‘<script async src=”https://www.googletagmanager.com/gtag/js?id=&#8217;.esc_js($tracking_id).'”></script>
    <script>
    window.dataLayer = window.dataLayer || [];
    function gtag(){dataLayer.push(arguments);}
    gtag(“js”, new Date());
    gtag(“config”, “‘.esc_js($tracking_id).'”,{‘.$ga_ip_anonymization.’ “cookie_domain”:”‘.$set_domain_name.'”});
    </script>
    ‘;
    echo $code;

    5) Submit the changes, clear the caches, and check about the custom dimension tracking.

    We hope this will work for you. please confirm the sending of custom dimension after following the above steps.

    Regards,
    Tatvic Analytics.

    Thread Starter willlweb

    (@willlweb)

    Hi there,

    But as soon as we update the plugin, these changes will be wiped?

    Also surely this is still going to mean duplicate tracking as it we are just adding a second gtag with the same tracking ID again.

    Thanks

    Plugin Author Conversios

    (@tatvic)

    Hi @willlweb,

    Currently, the addition of the custom dimension feature is not in the road map of our plugin. So, you would need to maintain this custom code change whenever you update our plugin.

    Also, the custom code doesn’t track the duplicate data. And to verify the same we had a look at your store and did not find any duplication related issue.

    We hope this helps.

    Regards,
    Tatvic Analytics.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Adding custom dimensions’ is closed to new replies.