• Resolved petschko

    (@petschko)


    Hey,

    we recently switched to this Plugin, because some of the “Marketing” guys were unhappy with the results of the old Plugin. I can’t tell since I’m not much into all this Marketing stuff

    But we gave the user the option to deny tracking by 3rd parties. I was doing that via this in our functions.php:

    
    if(class_exists('WC_Google_Analytics_Integration')) {
    	if(! allow_tracking())
    		remove_filter('woocommerce_integrations', array(WC_Google_Analytics_Integration::get_instance(), 'add_integration'), 10);
    }
    

    We still want to give the user this option, I just don’t found out how to remove the action(s) where your plugin adds all the stuff. You’re using some kind of loop to add actions/filters, so I would love to ask is there a fast way to build a similar construct like above?

    I look forward to hear from you!^^

    Petschko

    • This topic was modified 5 years, 11 months ago by petschko.
Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Conversios

    (@tatvic)

    Hi Petschko,

    Thank you for writing to us!

    Do you want to provide the user to choose whether their journey track in the GA or not? One type of use Google Analytics Opt-Out. Am I right?

    Regards,

    Thread Starter petschko

    (@petschko)

    Yes that’s right, we have a custom function which shows us if the user allow us to track them.

    But instead of an Opt-Out this is more of an Opt-In

    allow_tracking() returns true if the user allow us to track them else false (This function checks if 3rd party cookies are allowed and if the Do-Not-Track-HTTP-Header is set)

    Plugin Author Conversios

    (@tatvic)

    Hi Petschko,

    Unfortunately, this is something out of the scope of our plugin support. Our plugin has the option to choose the opt-out option in case you want to use it.

    Basically, our plugin is a Tracking Enhanced Ecommerce data in GA. It doesn’t fetch any personal data of the user of a website. If most of the user has opt-out from the GA tracking (functionality of our plugin) then no meaning to use our plugin.

    We are suggesting the same on the documentation of our plugin that enabling the opt-out will result in data discrepancy in your GA account.

    Hope you understand the concern!

    You can contact us directly at analytics2(at)tatvic(dot)com for further queries.

    Thanks & Regards,

    Thread Starter petschko

    (@petschko)

    Hm that’s sad to hear, we value the Privacy of our customers and just want let these help who want.

    I’m super sure your Plugin does not collect any personal Data nor give them to GA. It was more about disable the whole thing for users who don’t want it.

    I was raided by the Marketing to install this plugin, but I may have to search an other one. This sadly does not fetch our interests, I thought there was a simple hook I could use the remove the action, sad that there is no such hook, like in our old Plugin =/
    I can understand why Browser-Vendors slowly build in Auto-Tracking-Blocker like in Firefox, since most people think it’s okay to track users everywhere.

    Sure it adds data discrepancy, but that slowly happens anyway due to Auto-Tracking-Blockers from Browser-Vendors

    Anyway thanks for your time and for the reply =) I hope you have a nice weekend!

    Plugin Author Conversios

    (@tatvic)

    Hi Petschko,

    You can use the inbuilt script of our plugin for opt-out. You can read the steps in the document of the plugin.

    It visitor choose to opt-out from the tracking than plugin stop tracking their activity.

    Have a nice weekend!

    Regards,

    Thread Starter petschko

    (@petschko)

    We decided to still use this Plugin, also we still want to use an Opt-In, so we created this using the “OptOut” method to “hack” into it via the functions.php

    
    /**
     * Creates an GA-OptIn for the User to prevent tracking unless they allow this
     */
    function gaOptIn() {
    	$optOutCookieName = 'ga-disable-UA-xxxxxxxx-x';
    	$optOutCookie = (! isset($_COOKIE[$optOutCookieName])) ? false : $_COOKIE[$optOutCookieName];
    
    	if(! isTrackingAllowed() && ! $optOutCookie)
    		setcookie($optOutCookieName, 'true', time() + 307584000); // Add the opt-out cookie to simulate an opt-in
    	else if(isTrackingAllowed() && $optOutCookie)
    		setcookie($optOutCookieName, '', 0); // Remove cookie if tracking is now allowed
    }
    add_action('init', 'gaOptIn');
    
    

    We basically create the Out-Out Cookie by default on the user device, once they allow us to track them, we delete the opt-out cookie =)

    And with that solution we have an Opt-In for this Plugin, just wrote it here in case someone else want an Opt-In for this Plugin~ This function need to be called before any HTML output

    PS: The isTrackingAllowed() function is basically the source wherever you get value if the User allows tracking or not.
    In our case its a mix of getting the DoNotTrack-HTTP-Header and if the user itself allow us to track them~

    • This reply was modified 5 years, 10 months ago by petschko.
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Stop tracking via functions.php on a certain condition’ is closed to new replies.