I'm trying add Google URL Builder's functionality into my application.
https://support.google.com/analytics/answer/1033867?hl=en
Unfortunately, I'm not sure to get the exact results..
My code
def buildurl(url):
#take out old url builder
url = sub('\?utm_source=.*?(&|$)utm_medium=.*?(&|$)|utm_term=.*?(&|$)|utm_content=.*?(&|$)|utm_campaign=.*?(&|$)','',url)
#build url
header += '?utm_source=' + self.data['source']
header += '&utm_medium=' + self.data['medium']
header += '&utm_campaign=' + self.data['campaign']
#return long url
return(url header + urllib.quote(header)
My code returns this: http://iipdigital.usembassy.gov/st/english/article/2014/08/20140813305633.html#axzz3ANwb5XD?utm_source=source&utm_medium=medi&utm_campaign=testu
Google's URL Builder Returns this: http://iipdigital.usembassy.gov/st/english/article/2014/08/20140813305633.html?utm_source=source&utm_medium=medi&utm_campaign=test#axzz3ANwb5XDu
I could push the #axzz3ANwb5XDu to the back, but is there a way to parse and reconstruct the url in a standardized way?