WordPress.org

Ready to get started?Download WordPress

Forums

Google Analytics for WordPress
[resolved] [closed] 'Demographics and Interest Reports' in Google Analytics (61 posts)

  1. Scott Offord
    Member
    Posted 10 months ago #

    In order to get the Demographics (Age/Gender) and Interests (Affinity Categories) to work, Google Analytics is telling me that Tracking code changes are needed.

    GA says: "Your Analytics tracking code does not include the necessary support for the Demographics and Interest reports. Learn more about the simple, one-line, one-time change to your tracking code to add this support."

    https://support.google.com/analytics/answer/2444872?hl=en&utm_id=ad

    The instructions state that I should change this line from:

    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    To:

    ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';

    Does the Yoast GA for WordPress plugin support the new Demographics and Interests reports in Google Analytics?

    What should I do to allow this to work using your plugin?

    I've asked this question here too: https://github.com/Yoast/google-analytics-for-wordpress/issues/6

    Scott O.

    http://wordpress.org/plugins/google-analytics-for-wordpress/

  2. Mike Zielonka
    Member
    Posted 10 months ago #

    I'd love to see this change happen. This will help me a ton with getting remarketing working as well. :)

  3. doe.ely
    Member
    Posted 10 months ago #

    I would like to know what changes need to be done for this to work

  4. doe.ely
    Member
    Posted 10 months ago #

    I tried setting Host ga.js locally:: to http://stats.g.doubleclick.net/dc.js.
    Is this the right way of doing?

  5. wonderm00n
    Member
    Posted 10 months ago #

    +1 here

  6. bricem
    Member
    Posted 10 months ago #

    +1 !

  7. edei
    Member
    Posted 10 months ago #

    +1

  8. Scott Offord
    Member
    Posted 10 months ago #

  9. jennybhatt
    Member
    Posted 10 months ago #

    I'll add to this request. I'm not sure where to add this particular line either and don't want to mess up the current settings of the GA for WordPress plugin.

    Has anyone cracked this one yet?

  10. Dan Stephens
    Member
    Posted 10 months ago #

    +1

  11. irvitrad
    Member
    Posted 10 months ago #

    Don't expect an answer. It looks like questions are being answered sicne more than a year ago...

  12. Scott Offord
    Member
    Posted 10 months ago #

    I know how to use git, but I'm very rusty at it. So, I'd rather someone else take a crack at it.

    Mike, when are you going to commit your edit?

    Scott

  13. bowerszt
    Member
    Posted 10 months ago #

    Yes, please make this change. I'd love to start collecting this data!

  14. Marcelo Pedra
    Member
    Posted 10 months ago #

    I came here to second this feature as well.
    The plugin should allow the option to enable collecting demographics, thus using one or another js tracking script.
    Hope to see this implemented soon.

  15. kaleholdings
    Member
    Posted 10 months ago #

    Edit the file: google-analytics-for-wordpress/frontend/class-frontend.php

    COPY ALL OF THE TEXT IN THIS FILE AND PASTE IT IN NOTEPAD OR ANOTHER TEXT EDITOR JUST IN CASE YOU MESS UP (so you can revert back to the appropriate code).

    Search for ga.src

    you'll find this:

    -------------------
    ga.src = <?php
    if ( $this->options['gajslocalhosting'] && !empty( $this->options['gajsurl'] ) ) {
    echo "'" . $this->options['gajsurl'] . "';";
    } else {
    $script = 'ga.js';
    if ( current_user_can( 'manage_options' ) && $this->options['debug'] )
    $script = 'u/ga_debug.js';
    echo "('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/" . $script . "'";
    }
    ?>;
    ---------------------------------

    Change it to:

    ---------------------------------
    ga.src = <?php
    if ( $this->options['gajslocalhosting'] && !empty( $this->options['gajsurl'] ) ) {
    echo "'" . $this->options['gajsurl'] . "';";
    } else {
    $script = 'dc.js';
    if ( current_user_can( 'manage_options' ) && $this->options['debug'] )
    $script = 'u/ga_debug.js';
    echo "('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + 'stats.g.doubleclick.net/" . $script . "'";
    }
    ?>;
    -----------------------------------------

    Once that's done, hit "Update File".

    Go to the Plugin Settings page and Update Google Analytics Settings.

    It will repopulate your site with the new code. Be sure to verify it using Google Analytics.

  16. AccessWinnipeg
    Member
    Posted 10 months ago #

    You forgot to remove the 'ssl' and 'www'....

    Should be changed to this:

    ga.src = <?php
    if ( $this->options['gajslocalhosting'] && !empty( $this->options['gajsurl'] ) ) {
    echo "'" . $this->options['gajsurl'] . "';";
    } else {
    $script = 'dc.js';
    if ( current_user_can( 'manage_options' ) && $this->options['debug'] )
    $script = 'u/ga_debug.js';
    echo "('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/" . $script . "'";
    }
    ?>;
  17. Scott Offord
    Member
    Posted 10 months ago #

    That good and fine, but if the plugin gets updated in the repository, it will write over your edits.

  18. adamkushner
    Member
    Posted 9 months ago #

    I attempted this code and it breaks my site (loads a blank page)
    I have to remove the entire plug in and reinstall to resolve.
    What am I missing? I tried multiple times and audited the code line for line...

  19. Wonderful Wanderings
    Member
    Posted 9 months ago #

    Looks like we'll have to contact Yoast directly.
    Or stop using the plugin:/

  20. ruphel
    Member
    Posted 9 months ago #

    @KaleHoldings

    Your fix worked perfectly for me, thanks.

    I got it validated everything running smoothly, this fix should do until next update.

    Thanks

  21. ruphel
    Member
    Posted 9 months ago #

    Update:

    No didn't quite work Google Analytics stopped recording visits!

  22. Marcelo Pedra
    Member
    Posted 9 months ago #

    I prefer to wait for an official upgrade...

  23. Charles Cowens
    Member
    Posted 9 months ago #

    I would be happy to wait if I knew supporting this was actually going to happen anytime soon. Does anybody know any details about this?

  24. FastEddy760
    Member
    Posted 9 months ago #

    Demographics and Interest Reports

    Congratulations!

    You have successfully enabled the Demographic Reports. While you can access them now, it may take up to 24 hours before there is data available in these reports.

    Did the changes as described by kale holdings. Waiting to see if there is any data, after GA updates....

  25. tech_primosu
    Member
    Posted 9 months ago #

    Hey guys, just noticed on the YOAST website the following post:
    http://yoast.com/wordpress/google-analytics/faq/
    confirming that in order to make it work for the moment, we can enable the "Go to Host ‘ga.js locally" and add the URL https://stats.g.doubleclick.net/dc.js

    seems to be working so far, at least it got validated and it's not breaking my site, just waiting tomorrow for real data.

    bye!
    tech.primosu.it

  26. nbohnet
    Member
    Posted 9 months ago #

    @ tech_primosu
    Thank you, will check your post

  27. gabberkopf
    Member
    Posted 9 months ago #

    Tried the hint with ga.js locally but analytics still don't accept analytics code for demographic reports.

  28. Marcelo Pedra
    Member
    Posted 9 months ago #

    @tech_primosu
    Interesting, and the Analytics' source code is updated correctly, but the Analytics official website rejects to validate this. I compared the example provided by Google and the resulting code in my pages and it matchs every command. Don't know what the hell is wrong with Analytics website.
    Anybody else with similar issue?

  29. Marcelo Pedra
    Member
    Posted 9 months ago #

    @gabberkopf:
    Same here!!! Looks like there is something Analytics doesn't like.

  30. mackaaij
    Member
    Posted 9 months ago #

    The URL didn't validate at my site either.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic