Title: Adding custom dimensions
Last modified: May 7, 2020

---

# Adding custom dimensions

 *  Resolved [willlweb](https://wordpress.org/support/users/willlweb/)
 * (@willlweb)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/adding-custom-dimensions/)
 * 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](https://wordpress.org/support/users/tatvic/)
 * (@tatvic)
 * [6 years ago](https://wordpress.org/support/topic/adding-custom-dimensions/#post-12810594)
 * Hi [@willlweb](https://wordpress.org/support/users/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](https://wordpress.org/support/users/willlweb/)
 * (@willlweb)
 * [6 years ago](https://wordpress.org/support/topic/adding-custom-dimensions/#post-12814591)
 * 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](https://wordpress.org/support/users/tatvic/)
 * (@tatvic)
 * [6 years ago](https://wordpress.org/support/topic/adding-custom-dimensions/#post-12823197)
 * Hi [@willlweb](https://wordpress.org/support/users/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](https://wordpress.org/support/users/willlweb/)
 * (@willlweb)
 * [6 years ago](https://wordpress.org/support/topic/adding-custom-dimensions/#post-12823244)
 * 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/](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](https://wordpress.org/support/users/willlweb/)
 * (@willlweb)
 * [6 years ago](https://wordpress.org/support/topic/adding-custom-dimensions/#post-12839106)
 * Hi there,
 * Has there been any update on this one?
 * Thanks
 *  Plugin Author [Conversios](https://wordpress.org/support/users/tatvic/)
 * (@tatvic)
 * [6 years ago](https://wordpress.org/support/topic/adding-custom-dimensions/#post-12841222)
 * Hey [@willlweb](https://wordpress.org/support/users/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](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](https://wordpress.org/support/users/willlweb/)
 * (@willlweb)
 * [6 years ago](https://wordpress.org/support/topic/adding-custom-dimensions/#post-12845039)
 * 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](https://wordpress.org/support/users/tatvic/)
 * (@tatvic)
 * [6 years ago](https://wordpress.org/support/topic/adding-custom-dimensions/#post-12860448)
 * Hi [@willlweb](https://wordpress.org/support/users/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.

 * ![](https://ps.w.org/enhanced-e-commerce-for-woocommerce-store/assets/icon-256x256.
   gif?rev=2708061)
 * [Conversios: Google Analytics (GA4), Google Ads, Conversion and Analytics Tracking for Multi-Channels](https://wordpress.org/plugins/enhanced-e-commerce-for-woocommerce-store/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/enhanced-e-commerce-for-woocommerce-store/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/enhanced-e-commerce-for-woocommerce-store/)
 * [Active Topics](https://wordpress.org/support/plugin/enhanced-e-commerce-for-woocommerce-store/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/enhanced-e-commerce-for-woocommerce-store/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/enhanced-e-commerce-for-woocommerce-store/reviews/)

## Tags

 * [dimensions](https://wordpress.org/support/topic-tag/dimensions/)

 * 8 replies
 * 2 participants
 * Last reply from: [Conversios](https://wordpress.org/support/users/tatvic/)
 * Last activity: [6 years ago](https://wordpress.org/support/topic/adding-custom-dimensions/#post-12860448)
 * Status: resolved