module PlataformaSocial class UTM def self.add_utm_to_url url, options = {} settings = { utm_source: 'dito', utm_medium: nil, utm_campaign: nil }.merge options parsedURL = URI.parse(url) params = Rack::Utils.parse_nested_query(parsedURL.query).merge(settings) hash = '' if url.index('#') splittedHash = url.split('#') hash = splittedHash[1] url = splittedHash[0] end url = url.split('?')[0] + '?' + params.to_param url = url + '#' + hash if hash.present? url end end end