• Resolved petschko

    (@petschko)


    Hey,

    my Company want to opt-in people to Google-Analytics. This means it should be disabled by default and just become active when the user click on “accept”, else it should be disabled.

    Is there a hook or a great method to disable it and just enable it then?

    PS: I don’t want to opt-out (enabled by default) people, it’s important to have an opt-in (Disabled by default)

    Thank you for this great plugin so far ^^

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support dougaitken

    (@dougaitken)

    Automattic Happiness Engineer

    Hi there @petschko

    I don’t know of any way to have opt-out by default for Google Analytics. If this is available via their service then we can look into this but I don’t this that is an option.

    I also haven’t seen this as an option for any service.

    Thanks,

    Thread Starter petschko

    (@petschko)

    It would just help if there is a hook, which I can remove (Your function, which includes the Google-Javascript Code)

    Then I could just remove the call of the function, which includes the Javascript code to the head, else it would not removed.

    Something like that:

    
    function gaOptIn() {
        if(! userAllowGA()) // Function declared by me, returns true or false
        // remove_action(/* stuff to remove your function */);
    }
    
    • This reply was modified 8 years ago by petschko.
    • This reply was modified 8 years ago by petschko.
    Plugin Support dougaitken

    (@dougaitken)

    Automattic Happiness Engineer

    Hi @petschko

    If you can provide documentation to code directly from the Google Analytics team, we can take a look at this but as I mentioned, I’ve not see something like this implemented at all and cannot find anything readily online.

    Thanks,

    Thread Starter petschko

    (@petschko)

    May I didn’t wrote what I want.

    I don’t want to change the Google-JS-Code at all!

    Your Plugin just inplements the Javascript code in the HTML-Header via PHP, I want to know if there is a hook (Serverside – PHP), where I can stop your PHP function from implementing the JS-Code (Analaytics) to the HTML-Head.

    Thanks for the replies so far

    • This reply was modified 8 years ago by petschko.
    Thread Starter petschko

    (@petschko)

    Update:
    I took a look by myself into your Plugins-Code and found myself a solution (if anyone cares^^)

    I personally use the Cookie Notice from dFactory-Plugin, its super easy to see with php if the user want to accept cookies.

    You have just to add this tiny sniped to your functions.php:

    
    if(class_exists('WC_Google_Analytics_Integration')) {
    	if(! cn_cookies_accepted()) // returns false when user deny cookies (or not defined if he want) -> Opt in
    		remove_filter('woocommerce_integrations', array(WC_Google_Analytics_Integration::get_instance(), 'add_integration'), 10);
    }
    

    If you want an other control function, you can also replace “cn_cookies_accepted” with your function

    • This reply was modified 8 years ago by petschko.
Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘GA Opt-In / Hook’ is closed to new replies.