WordPress.org

Ready to get started?Download WordPress

Forums

Google Content Experiments
Fatal error: Call to undefined function wp_get_theme() (9 posts)

  1. Prok444
    Member
    Posted 1 year ago #

    When I paste the google experiments code, I receive this error message on the page:

    Fatal error: Call to undefined function wp_get_theme() in /home/prok444/public_html/wp-content/plugins/google-content-experiments/class-wpe-GCE.php on line 69

    Sso the page is completely blank except for that error message.

    I also tried adding this code to the beginning:

    <script>
    _udn = "mycreditdoc.com";
    </script>

    Here is the specific URL:
    https://mycreditdoc.com/what-is-the-credit-repair-doctor/

    Thank you for your help!

    http://wordpress.org/extend/plugins/google-content-experiments/

  2. glennm
    Member
    Plugin Author

    Posted 1 year ago #

    You need to upgrade your WordPress version.

    Please read the FAQ, where this question is answered.

  3. Prok444
    Member
    Posted 1 year ago #

    I don't get the error message now, thank you.
    Google Experiments says "No Experiment Code Found"

    I have deactivated the caching plugin, waited 5 minutes after saving page with code, and tried with and without the:
    <script>
    _udn = "mycreditdoc.com";
    </script>

    I looked at the source code and there is a part that says:
    <!-- Google Analytics tracking code not shown because users over level 8 are ignored -->

    Searching the internet doesn't give any good reasons for what and why?
    Not sure if this matters or not.

    Here is the URL:
    https://mycreditdoc.com/what-is-the-credit-repair-doctor/

    Thanks for your help, I'm really glad you created this plugin!

  4. glennm
    Member
    Plugin Author

    Posted 1 year ago #

    The

    <!-- Google Analytics tracking code not shown because users over level 8 are ignored -->
    is part of the Google Analytics for WordPress by Yoast plugin. There is a setting to ignore administrators, therefore the tracking code is not shown.

    I see that you're using the Thesis theme, which is not supported by default by the GCE plugin. Did you execute the additional steps which can be found on the Installation page?

    You need to insert <?php do_action( 'wpe_gce_head' ); ?> somewhere in the theme files. Without that code, the Experiment Code is not inserted, which explains why Google is not able to find it.

    Since I do not have access to Thesis theme files, I can't tell you where exactly you should insert the code.

  5. Prok444
    Member
    Posted 1 year ago #

    I appreciate your help. I've been working with the THesis support and the best we can do so far is get the code before the </head> tag. (Not right after the <head>)

    Google Experiments gives this message when checking for the code:

    The experiment code was found after the Google Analytics tracking code:line:22, column:124, line:90, column:1.

    Will this be an issue?

    Thank you for helping!

  6. glennm
    Member
    Plugin Author

    Posted 1 year ago #

    Hi Prok444,

    By default, WordPress is lacking an action hook to execute code right after <head>. That´s why you need to insert the action hook in the theme files.

    Some themes do provide an action hook right after <head>, which makes it easy for the GCE plugin to hook into those hooks. Supported themes that hook into an existing action hook are listed on the Installation page.

    According to official Google documentation:

    Issue: Your page has the Google Analytics tracking code before the experiment code. This can cause a problem with your experiment.

    Solution: Move the experiment code so it comes before the Google Analytics tracking code. In general, the experiment code should be right after the opening head tag.

    So: You might try to see if your experiment will work (although the experiment code is after the Analytics code), but I can't guarantee that it will work.

    Unfortunately there's nothing I can do, since this is a theme-related issue.

  7. Prok444
    Member
    Posted 1 year ago #

    Thank you for the quick response!
    I'm working with the Thesis team on their forum.

    Thank you for the great support!

  8. Prok444
    Member
    Posted 1 year ago #

    Hi Glenn,

    I think we finally figured out how to insert that code into the head.
    Now, I'm running into this error message:

    Tracking code missing the cookie domain name declared in experiment code:line:75, column:1, line:92, column:1.
    Your page customizes the cookie domain name in the Google Analytics tracking code. The same customization should be present in the experiment code

    I added this to the beginning of the experiments code like mentioned in your FAQ:
    <script>
    _udn = "mycreditdoc.com";
    </script>

    This is the page I'm trying to get it to work:
    https://mycreditdoc.com/what-is-the-credit-repair-doctor

    I have the google analytics plugin installed, but didn't see anything that "jumped" out at me to cause this issue.

    Do you know what else could be causing it?
    Here is the experiments code I have pasted in your plugin section on that page:

    <script>
    _udn = "mycreditdoc.com";
    </script>
    <!-- Google Analytics Content Experiment code -->
    <script>function utmx_section(){}function utmx(){}(function(){var
    k='52360893-1',d=document,l=d.location,c=d.cookie;
    if(l.search.indexOf('utm_expid='+k)>0)return;
    function f(n){if(c){var i=c.indexOf(n+'=');if(i>-1){var j=c.
    indexOf(';',i);return escape(c.substring(i+n.length+1,j<0?c.
    length:j))}}}var x=f('__utmx'),xx=f('__utmxx'),h=l.hash;d.write(
    '<sc'+'ript src="'+'http'+(l.protocol=='https:'?'s://ssl':
    '://www')+'.google-analytics.com/ga_exp.js?'+'utmxkey='+k+
    '&utmx='+(x?x:'')+'&utmxx='+(xx?xx:'')+'&utmxtime='+new Date().
    valueOf()+(h?'&utmxhash='+escape(h.substr(1)):'')+
    '" type="text/javascript" charset="utf-8"><\/sc'+'ript>')})();
    </script><script>utmx('url','A/B');</script>
    <!-- End of Google Analytics Content Experiment code -->

    Thanks for your help!
    Jeremy

  9. glennm
    Member
    Plugin Author

    Posted 1 year ago #

    Dear Jeremy,

    You don't need to insert the extra code, only the Google Content Experiment code. You're now declaring an extra cookie domain, which is not present in the Google Analytics tracking code.

    Delete

    <script>
    _udn = "mycreditdoc.com";
    </script>

    from the Google Content Experiments code field and only insert the code between
    <!-- Google Analytics Content Experiment code -->
    and
    <!-- End of Google Analytics Content Experiment code -->

    By the way: at this moment your code is still showing up before the </head> tag instead of right after the <head> tag, which might be causing issues with Google.
    Please let me know if you've found a solution for this with the Thesis support team.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic