Skip to main content
Level 2
Feb 22, 2021 3:51 PM UTC
Solved

Parsing URL minus domain & QSP to Page Name

Hi,

 

Apologies if this is mentioned but I couldn't find anything in Adobe documentation or on the forums.

 

A site I'm working on doesn't use a data layer and currently only passes URL into the Page Name variables. I'm looking for a workaround to pass URL minus domain and query string parameters into the Page Name var, possibly with slashes replaced by colons.

 

Is there a rule for this I can use within Adobe Launch? Assume it may require some custom code.

 

Thanks,

James

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Brian_Johnson_
Brian_Johnson_Accepted solution
Level 8
Feb 22, 2021 4:48 PM UTC

@jmaguire-1 -

The simplest approach might be to create a "page name" data element that parses the pathname per your requirements. 


Maybe start with something like this:

var path = document.location.pathname; if (path === "/") { // specify a default value if the path is "/" (assume home page) path = "homepage"; } else { // remove leading "/", then replace all remaining "/" with ":" path = path.replace(/^\//, "").replace(/\//g, ":"); } return path;

 

Then, in your rules, reference the data element. 

11 replies

Brian_Johnson_
Brian_Johnson_Accepted solution
Level 8
Feb 22, 2021 4:48 PM UTC

@jmaguire-1 -

The simplest approach might be to create a "page name" data element that parses the pathname per your requirements. 


Maybe start with something like this:

var path = document.location.pathname; if (path === "/") { // specify a default value if the path is "/" (assume home page) path = "homepage"; } else { // remove leading "/", then replace all remaining "/" with ":" path = path.replace(/^\//, "").replace(/\//g, ":"); } return path;

 

Then, in your rules, reference the data element. 

Translate
Level 2
Feb 22, 2021 5:07 PM UTC
Thanks, I'll give this a try.
Translate
PratheepArunRaj
Adobe Champion, Community Advisor, UG Leader
Adobe Champion, Community Advisor, UG Leader
Feb 23, 2021 11:29 AM UTC

Dear Jmaguire,

Why do you want to capture the pathname + Query String Parameters in the pagename? I would not recommend it because it will result in duplication of the pages.

URL: https://experienceleaguecommunities.adobe.com/adobe-analytics-questions/message-id/21725?q=test

Pagename: /adobe-analytics-questions/message-id/21725?q=test

You are trying to achieve the above right? If yes, please do not go for it, particularly in the Page Name variable.

Thanks, Arun.

Translate
Thank You, Pratheep Arun Raj B (Arun) | Xerago | Terryn Winter Analytics
Level 2
Feb 23, 2021 11:47 AM UTC

--- duplicate comment, Experience League site being very buggy today! ---

Translate