Expand my Community achievements bar.

Remove query string result in referrer tracking

Avatar

Level 1

Hi,

 

We have set up in Launch the referrer tracking to an evar, with following specs:

  • Extension: Core
  • Data Element Type: Page Info
  • Attribute: Referrer

In this variable we see query string parameters. We don't want to capture these values. 
I had found something like this online:

return document.URL.replace("/#!/", "")


But where do I put it (this Referrer variable uses an attribute, no custom code), do I need to put some code before/after it,... 

Hope someone can help me out. Thanks in advance

1 Reply

Avatar

Community Advisor

Hi @BYOID 

in this case, switch the Data Element Type to Custom Code and paste the code you that need to achieve your task.
Just make sure to return the value.

bjoern__koth_0-1742302014466.png


Note, your code is

  1. checking the current URL and not the referrer
  2. replacing a specific string in the URL, but not actually removing anything else than the exact string "/#!/"

 

So, If I may give you my quick suggestion how to tackle this. Two options, just use the line that suits your needs best

  1. cut off the hash string
  2. cut off the hash string AND the query string e.g., all that is following and including the question mark ?hello=world
// cut off just the hash string
return document.referrer.split("#")[0];

// alternatively, cut off both the hash AND query string
return document.referrer.split("?")[0].split("#")[0];

bjoern__koth_1-1742302079003.png

 

Cheers from Switzerland!