What's the best way to modify the raw URL to remove the protocal (Http://) or .com portions of the domain name?

Gold Contributor
Gold Contributor
I'm capturing the entirety of the URL currently as a default for the SiteCatalyst pageName. But I would prefer it match the format within google. So instead of http://www.mystite.com/dir/index.html, I want the url to display as www.mysite.com/dir/index.html. Simple, right? But what's the quickest and best way? Thanks in advance.
8 REPLIES 8

What's the best way to modify the raw URL to remove the protocal (Http://) or .com portions of the domain name?

Employee Emeritus
I am sure there are a few way to do this but one would be to use a set data values extension. Create a data source called something like pname Set pname to js code b['dom.url'].replace(/.*?:\/\//g, ""); Then map pname to pageName in your tag mappings. I am not sure about the code here but it should work with something like this. Hope it works

What's the best way to modify the raw URL to remove the protocal (Http://) or .com portions of the domain name?

Gold Contributor
Gold Contributor
The part in parenthesis is reg ex, correct? What does the "g" do here? Thanks, Jim. I've been following some of your questions so I figured you might have relevant experience. Seems like we are on the same path, more or less.

What's the best way to modify the raw URL to remove the protocal (Http://) or .com portions of the domain name?

Employee Emeritus
A less technical solution: A method would be to use the Join Data Values extension to join Domain (DOM) and Pathname (DOM) from your Data Sources in your Page Name variable that is/will be mapped in SiteCatalyst. For the Join Data Values extension, leave the separator blank (to avoid duplicate slashes) then, select Domain first and then Pathname second.

What's the best way to modify the raw URL to remove the protocal (Http://) or .com portions of the domain name?

Employee Emeritus
No problem. "g" means global so that it replaces all matches and not just the first match, so if there were multiple occurrences it would replace all.

What's the best way to modify the raw URL to remove the protocal (Http://) or .com portions of the domain name?

Employee Emeritus
an additional thought, if the end game is to create consistency between your GA data set and your SC data set then I would recommending mapping "pname" (as Jim names it above) to both the GA and SC page name variables so that the exact same data is being sent to both tags.

What's the best way to modify the raw URL to remove the protocal (Http://) or .com portions of the domain name?

Gold Contributor
Gold Contributor
Clint, the pathname (DOM) will exclude query parameters, correct?

What's the best way to modify the raw URL to remove the protocal (Http://) or .com portions of the domain name?

Employee Emeritus
yes it would.

What's the best way to modify the raw URL to remove the protocal (Http://) or .com portions of the domain name?

Gold Contributor
Gold Contributor
Excellent. This was very helpful. Thanks, guys.
Public