• Resolved andrecostainf

    (@andrecostainf)


    Hi there,
    thanks for the excellent plugin guys ! ??

    i’m trying to add siteSpeedSampleRate to the create function according to this: https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#siteSpeedSampleRate

    Analyzing the plugin code class-wc-google-analytics-js.php method load_analytics_universal line 214 to 249, I could use ga_set_domain_name to set that, but this field has esc_js, so, i cannot add this to domain name: ‘auto’ , {‘siteSpeedSampleRate’: 10}

    Is there any workaround for this? Maybe adding a filter to this field? This make any sense to you guys?
    If I can help with this, let me know! Please.

Viewing 1 replies (of 1 total)
  • Thread Starter andrecostainf

    (@andrecostainf)

    Hey guys!!!

    A few hours later, i was checking the code again, and found further down below the filters

    woocommerce_ga_snippet_output
    woocommerce_ga_snippet_require
    woocommerce_ga_snippet_create
    woocommerce_ga_snippet_head

    This one did the trick for me. If anyone need it, here is the snipped i’ve used:

    
    add_filter('woocommerce_ga_snippet_create', 'add_attr_siteSpeedSampleRate_ga_woo', 10,2);
    function add_attr_siteSpeedSampleRate_ga_woo($ga_snippet_create, $ga_id)
    {
        $ga_snippet_create = str_replace ( ")" , ", {'siteSpeedSampleRate': 10} )" , $ga_snippet_create );
        return $ga_snippet_create;
     
    }
    • This reply was modified 4 years, 9 months ago by andrecostainf.
Viewing 1 replies (of 1 total)
  • The topic ‘Add Attr siteSpeedSampleRate’ is closed to new replies.