WordPress.org

Ready to get started?Download WordPress

Forums

[Plugin: Google Analytics for WordPress] Google Analytics campaign variables in RSS (5 posts)

  1. Carlos Alonso
    Member
    Posted 5 years ago #

    Hi!

    I'm using the Google Analytics for WordPress plugin to track people coming from RSS.
    The plugin adds this to each url: ?utm_source=rss&utm_medium=rss&utm_campaign=rss

    How can I modify this variables, to put the title of each post as utm_source?

    Cheers!

  2. gerritduits
    Member
    Posted 5 years ago #

    I'm facing the same questing. I use my RSS feed for multiple services (Twitterfeed, facebook, e-mailnewsletter using RSS). For each servive, I want to change the utm_source.

    Is there an existing plugin for this?

    Alternatively, we could create a PHP-script, which pulls down the original feed, and replaces the values. This script must then be used as the RSS-endpoint.

  3. gerritduits
    Member
    Posted 5 years ago #

    Ah, screw it, I did it Myself allready. One note, the utm_'s were added twice by the plug-in(s). Therefore, you might want to modify $original_string to your situation.

    <?
    $data = file_get_contents("http://www.yoursites.tld/feed");
    
    $utm_source = "";
    $utm_medium = "";
    $utm_campaign = "";
    if (array_key_exists("utm_source", $_REQUEST)) $utm_source = $_REQUEST["utm_source"];
    if (array_key_exists("utm_medium", $_REQUEST)) $utm_medium = $_REQUEST["utm_medium"];
    if (array_key_exists("utm_campaign", $_REQUEST)) $utm_campaign = $_REQUEST["utm_campaign"];
    
    $original_string = "utm_source=rss&utm_medium=rss&utm_campaign=rss&utm_source=rss&utm_medium=rss&utm_campaign=rss";
    
    $new_string = "";
    if ($utm_source != "") $new_string .= "utm_source=".urlencode($utm_source)."&";
    if ($utm_medium != "") $new_string .= "utm_medium=".urlencode($utm_medium)."&";
    if ($utm_campaign != "") $new_string .= "utm_campaign=".urlencode($utm_campaign);
    
    $data = str_replace($original_string, $new_string, $data);
    
    echo $data;
    ?>
  4. ingejanse
    Member
    Posted 4 years ago #

    @gerritduits: thanks for this solution. Can you please explain what you mean with 'One note, the utm_'s were added twice by the plug-in(s). Therefore, you might want to modify $original_string to your situation.'? I'm not certain what this implies for me. Thanks in advance!

  5. herzzanu
    Member
    Posted 4 years ago #

    My problem is that Google sees as duplicate URLs. For ex:

    http://mysite.com/keyword1/keyword2/

    and

    http://mysite.com/keyword1/keyword2/?utm_source=rss&utm_medium=rss&utm_campaign=keyword2

    In Google Webmaster Tools it says that these two are pages with duplicate metadescription and duplicate title. Is this a major problem???
    And if it is what should I do?? I am waiting for an answer. Thank you.

Topic Closed

This topic has been closed to new replies.

About this Topic