• Resolved tobyrussell

    (@tobyrussell)


    At the moment I don’t think the plugin supports url fragments, for example

    https://www.google.com/#123

    becomes

    https://www.google.com/#123?{utm_codes}

    rather than

    https://www.google.com/?{utm_codes}#123

    Any chance of adding support. At the moment I’ve patched by modifying get_full_link() as follows:

    public function get_full_link()
    {
    $campaign_term = $this->campaign_term ? ‘&utm_term=’ . urlencode($this->campaign_term) : ”;
    $campaign_content = $this->campaign_content ? ‘&utm_content=’ . urlencode($this->campaign_content) : ”;
    $custom_pair_1 = ( $this->custom_key_1 && $this->custom_value_1 ) ? ‘&’ . urlencode($this->custom_key_1) . ‘=’ . urlencode($this->custom_value_1) : ”;
    $custom_pair_2 = ( $this->custom_key_2 && $this->custom_value_2 ) ? ‘&’ . urlencode($this->custom_key_2) . ‘=’ . urlencode($this->custom_value_2) : ”;
    $custom_pair_3 = ( $this->custom_key_3 && $this->custom_value_3 ) ? ‘&’ . urlencode($this->custom_key_3) . ‘=’ . urlencode($this->custom_value_3) : ”;

    if(preg_match(“/^(.*?)#(.*)$/”,$this->campaign_page,$campaign_page_matches)) {
    $campaign_page = $campaign_page_matches[1];
    $campaign_fragment = “#”.$campaign_page_matches[2];
    } else {
    $campaign_page = $this->campaign_page;
    $campaign_fragment = “”;
    }

    return $campaign_page . ‘?utm_source=’ . urlencode($this->campaign_source) . ‘&utm_medium=’ . urlencode($this->campaign_medium) . ‘&utm_campaign=’ . urlencode($this->campaign_name) . $campaign_t\
    erm . $campaign_content . $custom_pair_1 . $custom_pair_2 . $custom_pair_3 . $campaign_fragment;
    }

    Possibly not the most beautiful solution, but works for me.

    Lovely plugin by the way…. Cup of coffee on its way.

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Supporting url fragments’ is closed to new replies.