WordPress.org

Forums

Google Analytics by Yoast
[closed] Demographics and Interest Reports for Google Analytics (34 posts)

  1. PamelaMKramer
    Member
    Posted 1 year ago #

    Where in the plugin can we change this????

    To implement Remarketing or GDN Impression Reporting, replace the bold text in this example:

    <script type="text/javascript">
    var _gaq = _gaq || [];
    _gaq.push(['_setAccount', 'UA-xxxxx-y']);
    _gaq.push(['_trackPageview']);
    (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;

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

    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
    })();
    </script>
    with the bold text in the example below:

    <script type="text/javascript">
    var _gaq = _gaq || [];
    _gaq.push(['_setAccount', 'UA-xxxxx-y']);
    _gaq.push(['_trackPageview']);
    (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;

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

    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
    })();
    </script>

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

  2. mackaaij
    Member
    Posted 1 year ago #

    I have the same question. The line that should change is the ga.src=:

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

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

  3. Bob Bacon
    Member
    Posted 1 year ago #

    +1
    This is also discussed here: http://wordpress.org/support/topic/demographics-and-interest-reports-in-google-analytics

    The temporary workaround proposed by kaleholdings in the other thread didn't work for me or another user.

    I guess we are resigned to wait for Yoast to come out with an update.

  4. webicycoffee
    Member
    Posted 1 year ago #

    Also following this.

  5. webicycoffee
    Member
    Posted 1 year ago #

    The proposed hack on Yoast's FAQ did not work for me either.

  6. mackaaij
    Member
    Posted 1 year ago #

    Google Analytics didn't validate after I pointed to that URL at my site either.

  7. adminTripTrist
    Member
    Posted 1 year ago #

    I need the fix too.

  8. S3nd41
    Member
    Posted 1 year ago #

    When is the plug-in going to be updated to support this?

  9. jbug187
    Member
    Posted 1 year ago #

    In the last few days Yoast updated their Google Analytics FAQ to say that the Demographics and Interests reports are not currently supported. Prior to this update the FAQ had a workaround posted, which I had tried, unsuccessfully. Does anyone know if they plan on supporting these reports again at some point?

  10. adminTripTrist
    Member
    Posted 1 year ago #

    Is there anyway to delete the outdated code manually? Or maybe someone has a friend who can code who would like to fix all of our sites for us? I have the right code written in, but I just need to get rid of the bad code. (I think that would work.)

  11. petro
    Member
    Posted 1 year ago #

    +1

  12. mcg_
    Member
    Posted 1 year ago #

    +1
    Keen for a solution also.

  13. Besthand
    Member
    Posted 1 year ago #

    Modify:
    google-analytics-for-wordpress/frontend/class-frontend.php

    LINE 209 to:
    $script = 'dc.js';

    LINE 302 to:
    echo "('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/" . $script . "'";

  14. arcware
    Member
    Posted 1 year ago #

    Besthand is close, but has the wrong line numbers. The correct way to make this work is as follows (using version 4.3.3, which is the latest as of this writing):

    1. Use a text editor to open this file -> /plugins/google-analytics-for-wordpress/frontend/class-frontend.php

    2. Line 297 looks like this:

    $script = 'ga.js';

    Replace that with this:

    $script = 'dc.js';

    3. Line 301 looks like this:

    echo "('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/" . $script . "'";

    Replace that with this:

    echo "('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/" . $script . "'";

    That should do the trick.

  15. adminTripTrist
    Member
    Posted 1 year ago #

    Thank you for the help. To be clear I open this file. Change the code as listed above and save the file with the same name. Then zip the file, save it with the same name. Then delete the old plugin and and upload the new file.
    That is what I did - but no luck yet. Anything else we need to do?

  16. timaldiss
    Member
    Posted 1 year ago #

    Very useful, thank you.

  17. Peter Sejersen
    Member
    Posted 1 year ago #

    +1

  18. Bob Bacon
    Member
    Posted 1 year ago #

    I implemented the above code changes and nothing broke but GA still says, "Your Analytics tracking code does not include the necessary support for the Demographics and Interest reports."

    The beauty of Yoast's plugin is that you don't have to add tracking code to each page or header.

    Still waiting for an elegant solution...

  19. emips
    Member
    Posted 1 year ago #

    arcware: Thank you so much!

    bobbacon: After making arcware's changes, nothing changed for me either - so I deactivated & reactivated the plugin, and now it's working.

  20. howardpw
    Member
    Posted 1 year ago #

    +1

    Would be great if this could be added to the options page.

  21. lonelyunited
    Member
    Posted 1 year ago #

    emips:

    Will you be possible to see the change from the html code side? I just did what arcware recommended but when I pressed F12 on the web, I can see any change in my html codes. Thank you so much!

  22. andyvaughn
    Member
    Posted 1 year ago #

    Thank you Arcware - it worked for me.

  23. solstyce9
    Member
    Posted 1 year ago #

    arcware and emips tips worked for me.

    As an added measure, I cleared all my caches in w3ctotalcache after making the change and deactivating/reactivating Yoast.

    Thanks!

  24. BushwackerBen
    Member
    Posted 1 year ago #

    Thanks Arcware! worked for me as well!

  25. WolfieZero
    Member
    Posted 1 year ago #

    +1 for adding support natively. Not sure I'm a big fan of editing plugins as it will probably get overwritten when somebody else updates the plugin.

  26. BushwackerBen
    Member
    Posted 1 year ago #

    I noticed once I made edits to the code that google analytics reporting of search engine traffic dropped significantly. I made the edits in 4.3.4, and am changing the code back to see if it's the cause for the drop.

  27. Marios Alexandrou
    Member
    Posted 1 year ago #

    No doubt modifying the plugin code will work, but then you have to worry about overwriting those changes when the plugin is updated. Instead, consider using the Real-Time Find and Replace plugin (disclosure: this is my plugin) that allows you to swap out code after the page is rendered in real-time. No permanent changes to plugins or themes required.

    I've implemented the above solution and it works fine.

  28. wonderm00n
    Member
    Posted 1 year ago #

    Silence coming from Yoast...

  29. Fill in the Blank
    Member
    Posted 1 year ago #

    Just logged in to make sure you were all on this! lol... thanks

  30. howardpw
    Member
    Posted 1 year ago #

    +1 for Demographics support.

    You'd think after 3 months, we'd get a response from Yoast.

    Time to use another plugin?

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Google Analytics by Yoast
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic