Analytics
3.5K members online now
3.5K members online now
Ask questions about filter set-up and issues with using filters in Google Analytics reports
 
Guide Me
star_border
Reply

use query as custom dimension but filter query out of rapport

[ Edited ]
Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hi,

 

I would like to use the 'query' in domainname.com/?query (query could be city) as a custom dimension and at the same time filter the query so that the reports rapport clean URL's (without the query). Now when we use filter query and custom dimension it can't work because of filter. How we handle this?

Can/How we use the query as a custom dimension and at the same time filter the query out of rapporting so we can rapport clean URL's?

Kind regards,

 

Leon

1 Expert replyverified_user

Re: use query as custom dimension but filter query out of rapport

Top Contributor
# 2
Top Contributor
Hi Leon,

You can set the value of the custom dimension in your tracking code like ga('set', 'dimension1', 'city'); and add your query parameter to the Exclude URL Query Parameters field in your view settings so it will not be included in the reports. Let me know if you have questions.

Arnold Majlath, Google Analytics Top Contributor
Circle Me On Google+ | Visit me @ Redfly Digital

Re: use query as custom dimension but filter query out of rapport

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭
The queries would be generated based on the filter you choose to click on when filtering products. How does that work then?

Re: use query as custom dimension but filter query out of rapport

Top Contributor
# 4
Top Contributor

You need to use javascript or server side scripting to get the query parameter value into the GA tracking code. For example if your site is built in php the code would look like this:

ga('set', 'dimension1', '<?php echo $_GET['query']; ?>');

Hope this helps.


Arnold Majlath, Google Analytics Top Contributor
Circle Me On Google+ | Visit me @ Redfly Digital

Re: use query as custom dimension but filter query out of rapport

Visitor ✭ ✭ ✭
# 5
Visitor ✭ ✭ ✭
won't adding the query parameter to the Exclude URL Query Parameters stop the custom dimension from working? Currently we use 'Exclude URL Query Parameters' at view settings and push for the dimension.

Re: use query as custom dimension but filter query out of rapport

Top Contributor
# 6
Top Contributor
No, it won't affect the custom dimension as it is set using the 'set' command in the tracking code on the website.

Arnold Majlath, Google Analytics Top Contributor
Circle Me On Google+ | Visit me @ Redfly Digital

Re: use query as custom dimension but filter query out of rapport

Visitor ✭ ✭ ✭
# 7
Visitor ✭ ✭ ✭
How would that work with multiple queries and push set command via google tag manager?

Re: use query as custom dimension but filter query out of rapport

Top Contributor
# 8
Top Contributor

Hi,

 

I'll use this URL as an example: domain.com/?city=cityname&category=categoryname

The code snippet below will get the values from the URL and push them into the data layer:

<script>
dataLayer.push({
'city': '<?php echo $_GET['city']; ?>',
'category': '<?php echo $_GET['category']; ?>'
});
</script>

In GTM add the custom dimensions for your Universal Analytics tracking tag under More settings -> Custom Dimensions:

cd.png

The index should be the same number as in Google Analytics.

city and category are custom variables, data layer type, they will collect the values for the custom dimensions from the data layer. Let me know if you have more questions.


Arnold Majlath, Google Analytics Top Contributor
Circle Me On Google+ | Visit me @ Redfly Digital