title: Twitter button using iframe URL instead of original_referer
body: <p>I have a page on mydomain1.com that includes content within an iframe from mydomain2.com. Inside of the iframe I have coded a Twitter button using jQuery:</p>
  
  <pre><code>    // Twitter
      var twitterButton =
      '&lt;div&gt;' +
      '&lt;iframe allowtransparency="true" frameborder="0" scrolling="no" style="width:75px; height:85px;" ' +
      'src="http://platform.twitter.com/widgets/tweet_button.html' +
      '?original_referer=http://mydomain1.com/mypage/' +
      '&amp;amp;text=' + encodeURIComponent('This is my tweet message') +
      '&amp;amp;url=' + encodeURIComponent(bitlyShortUrl) +
      '&amp;amp;via=mytwittername' +
      '&amp;amp;lang=en' +
      '&amp;amp;show_count=true' +
      '&amp;amp;count=vertical' +
      '&amp;amp;hashtags=myhashtag' +
      '&amp;amp;size=m" &gt;' +
      '&lt;/iframe&gt;&lt;/div&gt;'
  </code></pre>
  
  <p>Then I use jQuery to include the above HTML in a DIV container inside the iframe:</p>
  
  <pre><code>    $('#buttonsDIV').html(twitterButton);
  </code></pre>
  
  <p>All of this code is contained in the mydomain2.com page. It works in that the Twitter button shows, can be clicked on and successfully submits the tweet including the bitly short URL. I am doing it this way because the button needs to be created dynamically based on user input.</p>
  
  <p>The problem is that the count always shows 0 (zero). When I hover the Twitter button I see that <code>original_referer=http://mydomain2.com/iframepage.html</code></p>
  
  <p><code>https://twitter.com/intent/tweet?hashtags=myhashtag&amp;original_referer=http%3A%2F%2Fmydomain2.com%2Fiframepage.html&amp;text=This%20is%20my%20tweet%20message&amp;tw_p=tweetbutton&amp;url=http%3A%2F%2Fwww.mydomain1.com%2Fmypage%2F&amp;via=mytwittername</code></p>
  
  <p>It seems that Twitter is using the URL of the iframe page instead of the parent page which is what we need to promote. Does anyone know why this happens and/or if there is a way around it?</p>
  
  <p>Also, will Twitter shorten the links itself? Of course, I am shortening it before submitting it. I've tried to submit the <code>url</code> without shortening it, but it's too long and the tweet ends up exceeding the 140 char limit. I have not seen that Twitter shortens it on its own.</p>
  
  <p><strong>EDIT #1</strong></p>
  
  <p>When I hover the Twitter Tweet button I not only see that <code>original_referer</code> is the URL of the iframe and not the parent page I specified, but I also see there is a querystring parm being added to it that is not coming from my code:</p>
  
  <pre><code>original_referer=http%3A%2F%2Fmydomain2.com%2Fiframepage.html%3Fundefined
  </code></pre>
  
  <p>which of course is <code>http://mydomain2.com/iframepage.html?undefined</code></p>
  
  <p>Btw, I have control of the pages/content on both domains - the iframe content and the parent page.</p>
  
  <p><strong>EDIT #2</strong></p>
  
  <p>One other detail is that <code>url=</code> is being set (by my jQuery code intentionally) with a bitly short URL that will vary due to a querystring parm that changes. It changes because we want users who follow the link back to our site and be able to see a video based upon the user's input who submitted the tweet in the first place. There are many different videos that could be played and so there is a querystring parm to tell our site which one to play - this is very important to us.</p>
  
  <p>I just noticed that this seems to have an effect on the count. If I remove the bitly short URL and instead use the same URL I specify for original_referer, the correct count displays. This however has no effect on the original_referer that gets changed to the iframe URL instead of the parent page URL.</p>
  
  <p>Yes, I am confused on this. Sorry for all the details, they just seem important to include. :S</p>