Analytics
1.6K members online now
1.6K members online now
Dive into multiple domain (Cross/Sub) tracking, implementing Ecommerce and Enhanced Ecommerce, setting up Event tracking, and Universal Analytics code.
 
Guide Me
star_border
Reply

JavaScript code to strip out extra URL parameters

Follower ✭ ✭ ☆
# 1
Follower ✭ ✭ ☆

Hi,

 

Although there are several methods to strip out URL query parameters like view settings, excluding URL parameters etc, I am apparently looking for a piece of code/syntax to be put in GA JavaScript code itself such that we will be able to take an action at code level. 

 

I do not want to go with any settings inside Google Analytics, it's just a method to show the reports without the parameters, but it send the info to the Servers, which shouldn't be the case with my requirement. 

 

Any inputs? 

 

Thanks,

Sri

 

1 Expert replyverified_user
1 ACCEPTED SOLUTION

Accepted Solutions
Marked as Best Answer.
Solution
Accepted by topic author Shashank S
July 2016

Re: JavaScript code to strip out extra URL parameters

Rising Star
# 2
Rising Star
Sri,

You'll need a JavaScript developer to split the url and clean it but this sounds very kludgy. It's certainly possible and your could simple pass the parsed document.location (without parameters) as a virtual pageview.

If you're using GTM it's much easier to shape the hit prior to sending it to Google Analytics.

Hey actually here is the reference on modifying the URL and they have a code sample that may help you! Smiley Happy

https://developers.google.com/analytics/devguides/collection/analyticsjs/pages#modifying_page_urls

Best,

Theo Bennett
Analytics Evangelist at MoreVisibility | Contact Me
Connect on LinkedIn

View solution in original post

Marked as Best Answer.
Solution
Accepted by topic author Shashank S
July 2016

Re: JavaScript code to strip out extra URL parameters

Rising Star
# 2
Rising Star
Sri,

You'll need a JavaScript developer to split the url and clean it but this sounds very kludgy. It's certainly possible and your could simple pass the parsed document.location (without parameters) as a virtual pageview.

If you're using GTM it's much easier to shape the hit prior to sending it to Google Analytics.

Hey actually here is the reference on modifying the URL and they have a code sample that may help you! Smiley Happy

https://developers.google.com/analytics/devguides/collection/analyticsjs/pages#modifying_page_urls

Best,

Theo Bennett
Analytics Evangelist at MoreVisibility | Contact Me
Connect on LinkedIn

Re: JavaScript code to strip out extra URL parameters

Follower ✭ ✭ ☆
# 3
Follower ✭ ✭ ☆
Thank you, Theo Bennett for your reply.
I shall try and share my response.