Hello Pradeep;
You might get several different correct approaches to this, but this was my way of how I got your scenario to work.
1. First, create a Data Source to map to your custom dimension in the Google Universal Tag. In my example, my Data Source is called "urlpartial" which will be the final variable that will hold your string the way you described. In my example, I am mapping to custom dimension 1.
2. Next, you will need a JavaScript Code extension to parse out the string as you require, and then set that to your UDO variable "urlpartial".
3. The code that I used in the extension is below. This uses JavaScript to find the segments of the url you are looking for with "--" and "-" as the markers (I assumed that all of your URL's have a final dash"-" before the 2014 with your samples above and use that as a final marker as you can see in code below).
Then it replaces your single dashes, with an underscore (if dash exists using regular expression global setting) per your requirements as you described.
{code:javascript}
var fd=window.location.pathname.indexOf('--');//find double dash
fd=fd+2;//increment to start after double dash
var ld=window.location.pathname.lastIndexOf('-');//find last single dash
var tp=window.location.pathname.substring(fd,ld);
utag.data.urlpartial=tp.replace(new RegExp("-","g"), "_");
{code}
This worked in my sandbox and sends the string to custom dimension 1 of GUA.
I have some screenshots attached as well to show you how I did this in a second post below (as a .pdf file was only way I could attach the shots)
Hope this helps!
-bahman
... View more