Not sure if it is a typo in the question, but instead of:
url = 'http://api.mixpanel.com/track/?data=%d&ip=1&img=1'%data
it should be
url = 'http://api.mixpanel.com/track/?data=%s&ip=1&img=1'%data
as the %d
expects a number, not a string, like %s
does