This is the 19th lesson video from my course The Exact Process For Setting Up Google Analytics – https://www.thequantifiedweb.com/exactga.
I decided to post the videos from the lessons publicly, but I encourage you to log into the course because from within the course you can access the written notes and the checklists, plus access my special offer. The course is completely free to register 🙂
This lesson is more relevant for businesses who have Ecommerce on their websites because they are more likely to have relevant data on the URL that would benefit from being turned into a custom dimension.
Basically, in this lesson, you’ll learn how to find the extra information on the URL that your website uses to talk to itself and store it in a more helpful place in Google Analytics. So for example, if you have fields on your website that sort products by an order, say price or product name, you might have a parameter orderby=price in your URL. Each of these different parameters breaks your pageview data because it changes the name of the page by adding all the extra data at the end.
In this lesson, I’ll teach you how to take the data off the URL and store it in another field called a custom dimension. This way you can finally see how many people visited each page on your website and where they came from. Your SEO team will be thankful!
Click to Open Transcription of Video
Hi! Welcome to Lesson Nineteen of the Exact Process for Setting Up Google Analytics by The Quantified Web. In this lesson, we are going to learn how to pull parameters off the URL. Now, if you have watched my other lessons, you, I would have taught you that parameters are pieces of information that a website tell, well the URL tells the website what to do on the website. We’re going to pull those parameters off the URL and we’re going to save them as Custom Dimensions in Google Analytics.
And this is helpful because the reporting view that we have set up, we’ve actually removed those parameters from the end and well that’s really helpful for being able to see exactly how many people looked up your page, that information might have been useful to you especially if you’re in e-commerce and so I suggest adding them as Custom Dimensions and then you can access them again in reports or if you’re manually looking through Google Analytics.
Alright, now this one is going to be somewhat more technical lesson than others and also we’re going to be using a, a tool, a Python script which I’m going to be running on some software called Cygwin. Now, you don’t need to follow that exact procedure if you don’t want to. You can also do it manually but I’m going to run through what I do and you can follow along and I’ve given you access to the Python script in case you want to.
Alrighty, so let’s go ahead and do it. So what you want to be doing is going to this website,
www.thequantifiedweb.com/exactga and put your email address in and click Get Started Today. Then you want to scroll all the way down to Convert Parameters to Custom Dimensions.
Alrighty, So I’ve just explained that anyway but basically, we’re going to be creating custom dimensions from the key parameters on the URL that are being stripped in the No Parameters view. Needs a little bit more interpretation and don’t worry about doing this if you are just using a — if you have a very basic website. It’s helpful if you have e-commerce, booking engines or other more complex websites that are putting parameters on the URL. But if you just have, like, a WordPress website and you’re just logging, it’s really, there’s not really going to be many parameters in there that you don’t want to keep. So that’s not going to be an issue.
Yes, so most small business lead generation sites don’t have much in the way of that. Alright, if you have a strategy plan and it turns out that you do have things that we want to keep then I’ll let you.
Alright, so for this tool I’m using something called Cygwin and this is some software that emulates the next —you don’t actually need to do it but I like running scripts using Cygwin because I used to be a computer programmer for 10 years and I used to use Linux, so that’s my, that’s my preferred tool. And I have put a tools folder under my G:/MyDrive/tools and you can put it wherever you like. The only reason why I’ve specified this is because later I’ve got a screenshot showing you how to do it and there should be a split_params.py script that — feel free to download it, you can use it as well.
Alrighty, so what we want to be doing is going to the Behavior, All Pages, sorry, Site Content, All Pages. It’s missing up here. Alright, now if you are just doing this by yourself then we want to go the Unfiltered Data but if you’re doing this as part of the setup then we actually need to go to the Filtered Data with No Params because your Unfiltered — your previous historical Unfiltered Data got turned into this view when we set up your Analytics. So this one historically has all of your Unfiltered. But in the future, if you’re to come and do this in a few weeks time then it would be the Unfiltered Data that we would want to use.
So now, we want to get a list of all the pages that have parameters on them. So, now I’ve just realized that I’ve come to the homepage, you know I’m talking and I haven’t gone to the right place. So let’s go there. Alright, now we want to get a list of all the pages that have parameters in them. So we want to type the question mark symbol in the search box which is here. Okay, and what that would do is it will find all of the parameters — now, actually, we probably want to change the date range.
Make sure that the search returns several different parameters, if not increase the period of time. Now, this particular website doesn’t have a lot of traffic so let’s just increase the amount of time. Look, there’s no exact amount of time that you need to apply, we just want to have several parameters in there. Alrighty, go aim for 3000-5000 pages of parameters if possible or two months of data, if not enough. The main thing we want to do is uncover the different parameters that are on the website.
Now, we want to change the row count because more than likely there will be more than ten. It always has just ten on there so we increase that based on how many rows you have. Now, if you see over here, you can see this is some examples of some of the parameters that are on this website. So we’ve got this one here sort_by=best-selling and then we’ve got another parameter that says &page=1. So there are actually two parameters on this. We’ve got sort_by and then we’ve got page.
And then we’ve got this one here has Variant. What else do we have? We’ve got one here that has channel=facebook and then you’ll see that you’ve got some that are not readable. Now, this is actually a Facebook ID. So Facebook is driving everybody back here at the moment by adding an ID at the end of everything that came from Facebook which means that you end up with like — so this slash here is the homepage and literally you just have like one person listed against being at the homepage because of all these Facebook IDs. This is one, oops, this is the key reason why you want to be stripping parameters off the end because it’s just ridiculous. You can’t read your Analytics report if it’s split up into individual one people.
Alright, well this gives us a bit of an idea anyway of the types of parameters that are in there. I’m seeing more so far variants, I’m seeing q which is for search and yeah that’s pretty much what I’m seeing. There might be some others in there.
Now, we want to export those to your computer. So we click Export and choose CSV and choose to Save the file. So it is important that you increase the number of rows first because if you only have ten rows list in there then you can only export ten lines which won’t give you all of the information.
Alright, so we want to click on Export and we want to pick CSV and it will say Exporting CSV, we want to Save that. Cool! So it’s going to quote something like this. Now, just for — if you’re using Cygwin, you might not be familiar with how to use Linux, so I recommend renaming it to a file without any spaces. So let me just go and find it and I recommend putting that in wherever your Cygwin, sorry, wherever the Python script is, wherever you’ve installed that. So I put mine under tools. So I’m just going to put that in there.
Alrighty, now this is actually for my team. I don’t think it’s public. So this link won’t work for you, unfortunately. Alrighty, so we want to put it in the — put the CSV file in the same folder as where you have your Python script. Now, my team member has Cygwin typed in but I’m familiar with using Linux so I tend to use the tab key and I do it — basically if you hit tab well then know the system that it will order the way it populates it.
Alrighty, so we need to do python3 split_params.py, that’s the name of the script that I’m using and I called mine exact-process-ga-example, oops, I end up with two csvs. It doesn’t matter. And what that’s going to do is it’s going to read the file. It ain’t a bit slow. Oh, it just took a long time. That’s strange. Alright, I was getting impatient.
Alright, so what it’s done is found all of the parameters that were in that data sample and it’s got the name of the parameter and how many instances there were. And then it has all of those listed out in the line as well, in case we want to add them somewhere else. We’re not going to go through doing that.
Alright, so we can see that sort_by has been used twice, page and we’ve got this variant, twenty-two times, that’s obviously pretty common. We have twenty-four instances of Facebook annoying our users that were there, annoying us. We’ve got a couple of search queries and then this one, it looked like there was some kind of a custom thing, it just had channel=facebook.
Alright, so these are the types of parameters that we’re dealing with on this website. You will have different ones. Some of them you’ll have will be similar but you may have different ones and it also depends on which system you’re using. So if you’re using an e-commerce system you might find that you’ll have some of the same ones as other people using the same e-commerce system as you.
Alrighty, so we want to come up with a list of parameter inclusions from that. So basically, what we want to do is pick out the ones that you think you’re going to be useful to keep. Now, the ones that I would keep on here would be — so we wouldn’t want to keep the search one because that’s kind of a, we’re using it elsewhere. So we already got that search term being used.
But I would keep the sort_by, so I’ll just make a note of that, we want sort_by and I would want to keep variant. I wouldn’t, I wouldn’t want to keep any others, that’s not really useful. And it’s good actually that this particular client doesn’t have a million of them because it makes it easier for me to show.
Alright, so if there’s some that you’re really not sure, just write it as a list of maybes then you can investigate them. So you can, you can systematically go through each maybe and check them and if you’re not sure about one — so let’s just say we wanted to look at what that channel was. Now, I totally see what the channel was but I’m just going to show you. So, actually, no. No. we’ll just do that.
Alright, so what we’ll do is we go back into here and we will, instead of having just question mark, we will type in this word here, yeah, have I explained? Okay, I haven’t really explained it very well how to do that. So instead of having this question mark, we would put in the actual parameter itself so we’re going to check for Channel.
Alright, and basically so we want to see if this is a useful parameter or not. So we’ve typed in that parameter name and we just want to see whether this is a parameter that we care about keeping. Now, I’m not going to worry about this because we already have channel coming in through other means but this will help you to see if it’s human-readable or not.
So what we’re looking for are things that are either human-readable because they have text or something where a particular number maps to a particular value so in this example here we got color=4 where 4 maps to something specific and those can be really useful as custom dimensions.
Alrighty, so another thing you might have is you might have a value that matches an ID from other software. So you might have a Mailchimp ID for example. So even though it’s not human-readable it’s still useful because if you want to map an ID back to your software then you can just pull up straight out of Google Analytics.
Something’s are just completely not human-readable and you just don’t even want to include them. There’s no point in having custom dimensions for things that you don’t know what they are anyway. They’re just, they’re just for the software. Alright, we want to reduce the list to no more than 15 custom parameters preferably no more than 10-12 and in this case, we’ve only got two.
So let’s go through the first custom dimension that we’re going to create. So we want to go to Admin and select Custom Dimension from the drop-down menu and that is under Property. So let’s go Admin and under Property Settings, we go down to Custom Definitions and Custom Dimensions. Then click on New Custom Dimension. This client doesn’t have any Custom Dimensions. You may or may not have some. Most people don’t have them.
Alright, so let’s give it a name that is human-readable. So the one that I’m going to do now is sort_by. So I’m going to do it as sort order because I think that makes sense. And we want to choose Hit. So Hit means every time that happens it will save it in Google Analytics. And we want to click check Active and once it has a check and then click Create.
You’re going to get a window that looks like this and you want to click Ok to that or Done and then we want to do one for each so luckily, this one is super easy because we’ve only got two. I’ve just given some examples here.
Now, if you open the Filtered Data No Params view in a new tab, we are going to create some filters that will let us turn these into Custom Dimensions. Alrighty, so we want to go to Admin and we want to select Filtered Data No Params again, yeah, we’ve got that one and if there is an on-site search parameter in the parameters list, edit the view, check to make sure, oh okay.
So in the parameters list here we had, this one here q, q is for searching. That’s for an on-site search. So we’re just going to double-check that we did correctly set it up. Alright, I do recall that we did it but let’s just check anyway. So it’s under View Settings. We just want to make sure that we have q in there and we do. Alrighty, now I can just hit Cancel instead of Save because I didn’t change anything.
Now, we are going to add a filter. So go Filters, we want to go Add Filter. Now, the purpose of this filter is to turn this custom dimension or the, we’re going to turn the parameter that was in the URL that we got rid of into a custom dimension in Google Analytics and the filter is going to do that for us.
Alrighty, so refer to the list of custom dimensions open in your other tab. Alright, so we have two custom dimensions here. Index 1 and index 2. Let’s just pick the first one. So we’re going to pick sort order. Now, if you, if you click on that then you can copy the text directly.
Alright, so what we are going to do we are going to create a new filter and we’re going to name that the same name so that it’s really easy for us to know what we’re referring to because it’s the same one and we are going to make it Custom and we’re going to set it to Advanced. Now, actually, if you want to make it even easier you could call it custom dimension sort order. I probably should have specified that in the procedure actually but I’m in the habit of making it easier on myself to get through this quickly but you might find that easier actually to call it custom dimension sort order.
Alrighty, and then we want to — now, this is a little bit tricky, this part here. We want to actually copy, oh we haven’t got that like little symbol that we had in some of the earlier symbols but we want to copy this exactly. So in — actually, I’ve skipped it, to Advanced and in the Select field here we want to pick Request URI. So that Request URI that is the URL across the top. So we want to pick this text and we need to replace the ID with the parameter from here from Cygwin. So in this case, it is sort_by. Alright, that was a couple of examples.
Now, under the Output 2, we type in $A2 and this Constructor, we need to pick our custom dimension in here. Now, if you scroll down a bit all the way down the bottom and we want it to be down here and we want to go $A2. So what this is doing is taking the value of the parameter and it’s going to save it in that custom dimension. Alright, I’m going to save that one. We want to do that for all of our custom dimensions.
So I’ll just do another one quickly and this one is going to be variant, custom, okay it was that one. You can just go back and see it again. So it was Advanced, we do Request URI in here and then here we picked variant. So we want to copy this. I’m going to put it in here. I’m going to replace this ID with the actual parameter. So in this case, it will be variant and then under variant, we do $A2. So I know that is just so geeky, I’m really sorry to hurt your brain. Alrighty, click Save.
Alrighty, so we want to re-order the filters again so that the removing parameters and removing the trailing slashes are at the end. Now, we probably don’t need to add this custom dimensions to any other views. It’s unlikely that you would be using them all the time. So if you just add them to Filtered Data No Params view, that’s the only one that’s really relevant and to be honest, the other filtered data still has parameters in there so the other one will actually have them on the URL. So it’s just this one view that we want to change.
So now if we go into Filters, oh I was in there. Assign Filter Order, we want to go and re-order the filters so that the remove parameters and remove trailing slashes are at the end. So you can see now that these ones have been put to bottom so let’s just move them up. Move this one up and then what it will do now is it will take the custom dimension out, put it in a — or take, it will take sort order parameter out and put it in this custom dimension. It will take variant out and put it in a custom dimension and then it will remove all the parameters so that way we can save it. If you have them around the other way around, it will remove all the parameters first and then you won’t be able to find them.
Now, we need to wait a couple of days to make sure that that’s working. So I can’t do that straight away. But we want to just test that that’s working because it’s really easy to make a mistake when it comes to copying that text. So the first thing we want to do is test the Search Query Behavior is set correctly by going to Site Search, Searched Terms.
Now, it will not show you in here because it’s been less than 48 hours. But if you go to Searched Terms, you should start seeing any searches coming through in here now. So basically, you want to see, you want your graph to be looking like, like something’s happening. And then you want to test that your Custom Dimension filters are working correctly.
So the way that you would do that is — so you’re already in this Behavior –> Site Search –> Searched Terms, it doesn’t really matter what report you’re in but let’s just go in here anyway let’s see if it is doing anything. Yeah, so no one has done any searches since yesterday when I recorded that one but what you would do is — actually it’s probably best to go into an Acquisition one for this rather than Site Search. So just go to All Traffic –> Channels and then choose a Secondary dimension of the Custom Dimensions that you’ve created and if it’s working correctly then you should have data now coming into this field here. Obviously, we’ve only just set it up in this case so there’s nothing coming through yet.
You need to leave enough time, so I’ve set 48 hours but you need to leave enough time if someone’s actually tried to do this. Though if it’s not working straight away then you just come back again after a week or so.
Alrighty, well hopefully that just didn’t explode your head too much. I know some of these analytical things can be a little bit detail-oriented and not everyone’s into that. So if that’s the case, I’m sorry if you found that painful but hey, my team really love this stuff so if you have anything like this that you want some help with just, just shout out to us. We’ll give you a hand with that.
I think we’ve got a little link here, here you go, you can click on Support and you can just contact us if you want us to help with. Okay, so in the next lesson, we are going to go through Configuring Custom Channels and then we’ve only got a few more lessons left and then you are done. So Configuring Custom Channels next and I will see you on that lesson.
If you liked this video and want to find the next one, look out for the article How To Configure Custom Channels in Google Analytics. This next video shows you how to fix up all of your Sources and Source / Mediums into custom channels so that you can report your most relevant incoming traffic streams, rather than trying to deal with painful aggregation issues like facebook.com and m.facebook.com and lm.facebook.com and a million different flavours of Pinterest. In my opinion, every business should configure custom channels, so don’t miss that one!