Question: I'm trying to put a Twitter share link in an email. Because this is in an email I can't rely on JavaScript, and have to use the "Build Your Own" Tweet button.

For example, sharing a link to Google:

```
<a href="http://www.twitter.com/share?url=http://www.google.com/>Tweet</a>

```

This works fine. The problem I'm having is when the URL has a query string.

```
<a href="http://www.twitter.com/share?url=http://mysite.org/foo.htm?bar=123&baz=456">Tweet</a>

```

URLs with query strings confuse Twitter's URL shortening service, t.co. I've tried URL encoding this in various ways and cannot get anything to work. The closest I have gotten is by doing this.

```
<a href="http://www.twitter.com/share?url=http://mysite.org/foo.htm%3Fbar%3D123%26baz%3D456">Tweet</a>

```

Here I've encoded only the query string. When I do this, t.co successfully shortens the URL, but upon following the shortened link, it takes you to the encoded URL. I see `http://mysite.org/foo.htm%3Fbar%3D123%26baz%3D456` in the address bar, and get the following error in the browser

> 
> Not Found
> 
> 
> The requested URL /foo.htm?bar=123&baz=456 was not found on this server.
> 
> 
> 

I'm at a loss as to how to solve this problem.

**Edit:** Re: onteria\_

I've tried encoding the entire URL. When I do that no URL shows up in the Tweet.

Answer: 
As @onteria\_ mentioned, you need to encode the entire parameter. For anyone else facing the same issue, you can use the following bookmarklet to generate the properly encoded url. Copy paste it into your browser's address bar to create the **twitter share url**. Make sure that the `javascript:` prefix is there when you copy it into address bar, Google Chrome removes it when copying.

```
javascript:(function(){var url=prompt("Enter the url to share");if(url)prompt("Share the following url - ","http://www.twitter.com/share?url="+encodeURIComponent(url))})();

```

Source on JS Fiddle
<http://jsfiddle.net/2frkV/>
Twitter now lets you send the URL through a data attribute. This works great for me: 

```
<a href="javascript:;" class="twitter-share-button" data-lang="en" data-text="check out link b" data-url="http://www.lyricvideos.org/tracks?videoURL=SX05JZ4FisE">Tweet</a>

```