vendredi 20 mai 2016

Call WP plugin function only if certain condition is met

I am willing to use a GA plugin (Google Analytics, ex-yoast, now by Monsterinsights), but I would like the functions of this plugin to be called ONLY if ceartain conditions are met - in my case, if users accept cookies. I found EU Cookie Law, a nice Italian plugin that provides a simple way to execute some code, only if users opt in/

if ( function_exists('cookie_accepted') && cookie_accepted() ) {
    // Your code
}

Now, I could put GA code there, but I would like very much to benefit GA plugin advanced functions. But I wonder what would be the appropiate strategy (and code) to kind of "desactivate" GA plugin and activate it only "if cookies accepted".

Any idea?

Thanks, Agnes



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire