For your code that parses the URLs, are you looking for query string parameters, or other parts of the URL? If you use Data Elements for those URL values, you can set your Analytics variables in the user interface in the global Analytics settings, Pageviews & Content section.
When you say you "entered the code into the Customize Page Code interface in the Analytics section of DTM", did you do that in a Page Load Rule, or on the Global Settings screen?
For troubleshooting tips and training, check out the Troubleshooting Rules video, the Debugging video, and the DTM Basics-Debugging video. Also check out the DTM Switch Chrome browser plugin.