Good afternoon.
I would like to know how to parse the URL in the TAG and send it in separate variables to Analytics.
Thanks.
Solved! Go to Solution.
Views
Replies
Total Likes
I generally use Custom Code Data Elements for that... how good are you with JavaScript, and how complex are your parsing rules?
If you just want a simple part 1, part 2, part 3, etc IF it exists, then you could so something like:
var pathName = _satellite.getVar('urlpath');
pathName = pathName.replace(/\/*$/, "").replace(/^\/*/, "");
var pathNameArray = pathName.split('/');
var urlPart = "";
if (pathNameArray[0]){
urlPart = pathNameArray[0];
}
return urlPart;
The first part just gets the Path Name from another Data Element for Path Name (or you could pull that using JS, but if you already have it, might as well use it)
The second line just removes the leading and trailing / from your path (when you split the path, you won't end up with empty objects)
Next, we are going to split the URL into an array on "/" - basically making each part of the URL it's own object.
All of the above code will be in each Data Element... the next part has the variations.
First, we just initiate a urlPart variable, so that when we run the return statement, the variable is defined, and if you happen to be on the home page, with no path parts, it will just be an empty value, or when you are pulling part 3, and you only have 2 parts, again, it returns an empty string.
Now, for each Data Element, we want to check IF there is a URL part at the position, arrays are zero-indexed... so "0" is actually part 1, "1" is actually part 2, etc
If there is a value in the part, set the urlPart variable to the value.
I generally use Custom Code Data Elements for that... how good are you with JavaScript, and how complex are your parsing rules?
If you just want a simple part 1, part 2, part 3, etc IF it exists, then you could so something like:
var pathName = _satellite.getVar('urlpath');
pathName = pathName.replace(/\/*$/, "").replace(/^\/*/, "");
var pathNameArray = pathName.split('/');
var urlPart = "";
if (pathNameArray[0]){
urlPart = pathNameArray[0];
}
return urlPart;
The first part just gets the Path Name from another Data Element for Path Name (or you could pull that using JS, but if you already have it, might as well use it)
The second line just removes the leading and trailing / from your path (when you split the path, you won't end up with empty objects)
Next, we are going to split the URL into an array on "/" - basically making each part of the URL it's own object.
All of the above code will be in each Data Element... the next part has the variations.
First, we just initiate a urlPart variable, so that when we run the return statement, the variable is defined, and if you happen to be on the home page, with no path parts, it will just be an empty value, or when you are pulling part 3, and you only have 2 parts, again, it returns an empty string.
Now, for each Data Element, we want to check IF there is a URL part at the position, arrays are zero-indexed... so "0" is actually part 1, "1" is actually part 2, etc
If there is a value in the part, set the urlPart variable to the value.
Use the Core > Page Info data element. It can parse out any part of the URL, even specific query parameters. No coding required!
Core > Page Info (Pathname) gets the path as one single element... it doesn't parse it into separate parts.. unless I am misunderstanding the question....
It sounded to me like they want "part 1" of the path going to eVarX, and "part 2" of the path going to eVarY, and so on.....since they said:
and send it in separate variables to Analytics
but maybe they just mean into parts like "domain" and "path"... in which case, yes, the Core > Page Info is sufficient.
Views
Replies
Total Likes
I interpreted the original question to be parse the parts of a URL, i.e. hostname, pathname, query, fragment.
@afonsoAmorim please clarify what are the parts that you want to parse. If it is the pathname that you want to parse, i.e. split by "/", consider tracking the entire pathname to your eVar, then use Classifications Rule Builder to split out the parts.
Yes, the question is pretty open to many interpretations... and yes, classifications can be used if you don't need the data to be available right away, or to be used to build other data elements with logic or concatenation rules.
Understanding the use cases would help us to help you properly
Hi @Jennifer_Dungan and @yuhuisg.
I would like to cut the URL into several parts and send it to Adobe Analytics, below is an example URL.
https://dsn.adobe.com/web/patrick.lima@netbiis.com-TFW7/home
In this case, I would like the word patrick to be in an eVar and file in another eVar in Analytics, for example:
eVar10 = 'patrick'
eVar22 = 'lima'
I am not able to create the rule or data element for this case.
Views
Replies
Total Likes
so you are trying to parse an email address out of a URL? How can you be sure that there will always be a . in the email address? How can you be sure the email address is actually a name?
And from a PII standpoint, why is there an email address coded into the URL in the first place?
The code I posted the first time around showed parsing the URL Path by the /... this would require extended JS coding, but could be done in a similar way... but the problem is that the value may not always be populated in this format, so we would also need to understand what should happen for other email formats.....
Views
Replies
Total Likes
Jennifer, how do I capture this URL and send it to Analytics. Should I create a rule or a data element?
Do you have any tutorial on how to capture this URL and send it to Analytics?
Views
Replies
Total Likes
As @yuhuisg pointed out, you can create Data Elements using Core > Page Info to get lots of things relating to the page:
URL - gets the full URL (https://www.domain.com/something/x)
Hostname - gets the domain of the url (www.domain.com)
Pathname - gets the path (/something/x)
Protocol - gets the protocol (http: or https:)
Referrer - gets the referrer value from the header of the page
Title - gets the doctitle (the SEO title, what shows in the tab, etc) of the page
So in your case, starting with Pathname is likely the option you want... but parsing out values... well that all depends on the structure of the URL, how complex you want to make the parsing, etc...
Trying to extract parts of an email which is encoded into the URL, in particular trying to parse the local part (or username) of the email when this can support many different formats and character will make this ask more difficult....
Your sample used first.last@domain.com and you want to split the username into first and last... but there may not always be a ., it might have a - (first-last) or an _ (first_last) or nothing at all (firstlast or flast).... there may be no consistency on which to properly parse such information...
I believe that he wants to use a delimiter, for example what is between "/" or what is separated between "&", or "@" or any other symbol...
Yes, that was my interpretation as well, which is why I provided parsing based on "/" in my first post
Views
Replies
Total Likes
Would there be a way to collect UTM data via AEP? If yes, what would be the step-by-step?
Views
Replies
Total Likes
There is a data element to collect query parameters as well.... now, those will be captured one by one, so if you are using UTMs you probably have the 5 standard parameters to capture...
If you want these to be passed to Adobe's "campaign" dimension, then you will have to concatenate the values from the various Data Elements into the format of your choice....
I personally would use a Custom Code Data Element to bring all the UTM Data Elements in, then check if they have values, then build them together into the format I want/need...
If you just add them directly into the campaign variable like so:
When you don't have any UTMs, you will end up with a series of underscores "____" being passed, which likely isn't what you want.
Views
Likes
Replies