title: base64 encode a JSON for Mixpanel API pixel tracker
body: <p>According to <a href="https://mixpanel.com/docs/api-documentation/pixel-based-event-tracking" rel="nofollow">Mixpanel doc</a>, I need to base64 my json array before sending it to their API endpoint</p>
  
  <pre><code>json = {"event": "e-mail opened", 
          "properties": {
          "distinct_id": "28224", 
          "token": "494f5d201963457e632d463d1d4745e4", 
          "time": int(time.time()), 
          "campaign": "gameweek 27"
              }
      }
  </code></pre>
  
  <p>Per the doc, I need to send it like that</p>
  
  <blockquote>
    <p>http://api.mixpanel.com/track/?data=[BASE_64_JSON_EVENT]&amp;ip=1&amp;img=1</p>
  </blockquote>
  
  <p>Here's my python code to convert the dict to base64 and send it. I get</p>
  
  <p><code>data = base64.b64encode(json.dumps(json))
  url = 'http://api.mixpanel.com/track/?data=%d&amp;ip=1&amp;img=1'%data
  requests.get(url)</code></p>
  
  <p>My problem is that it doesn't track anything. If I convert the same dict using <a href="http://www.percederberg.net/tools/text_converter.html" rel="nofollow">this online converter</a> and construct the url manually it work.</p>
  
  <p>So there's probably something who's not working in my encoding but what?</p>
  
  <p>Thanks!</p>