The ROI Revolution Blog

Exact Keyword Tracking with ga.js

February 14, 2008


Sleuth! Magnifying glass icon.Last April, I posted a script that allowed paid search advertisers to view the exact search queries of their visitors. This was essentially a free tool that gave website owners the ability to weed out ineffective keywords and put more money toward the precise phrases that were really driving their business.

Google Analytics doesn't do this out of the box. It will tell you exact search queries for visits from organic listings, but for paid search, you're stuck with the keywords that you're bidding on. With broad and phrase matching, these could vary pretty drastically from what the visitors typed into the search engine.

We've gotten a lot of requests to update the script for the new version of the Google Analytics JavaScript, ga.js. Always happy to oblige, we've been hard at work on our new version of the Google Analytics Keyword Sleuth. Call it a Valentine's Day gift from ROI Revolution to you.
Using ga.js?

If you've upgraded to ga.js, then you'll need to grab the new ga_keyword2.js file from our server and upload it to yours. Make a note of where you put it.

Now, update your Google Analytics Tracking Code:



The only addition is <script src="/path/to/ga_keyword2.js" type="text/javascript"></script>. Be sure to update this line so that it actually points to the script. And, of course, be sure to update the UA-XXXXXX-1 number with your own Google Analytics profile number.

Still Using urchin.js?

If you haven't updated to the new version of the Google Analytics JavaScript, fear not. We're still working on ways to improve our script for urchin.js. So, since we've made a few improvements to the script, you'll probably want to update yours with the most recent version.

You can get the latest ga_keyword.js file from our server and upload it to yours. Make a note of where you put it.

Then update your Google Analytics Tracking Code:



Again, the only addition is the line: <script src="/path/to/ga_keyword.js" type="text/javascript"></script>. Be sure to update it so that it points to the script. Also, update the UA-XXXXXX-1 number with your own Google Analytics profile number.

Please bear in mind that this script is presented as-is. We've tested it extensively with our own Google Analytics accounts, but your mileage may vary. If you have any major problems, let me know in the comments. We're always working to improve the script, so keep posted on the blog for updates. You can sign up for our email newsletter, or keep track via RSS.

As a quick aside, I knew there was demand for this tool when I developed it, but I'm still amazed at its popularity. Internally, it is one of the most widely requested features from our pay-per-click teams, and I love that they're using it to really help our clients maximize their ad spend. There's a rumor going around that they're planning on unveiling some of the cool ways that they use exact keyword data right here on the blog, so... all the more reason to add the RSS feed to your reader of choice so you don't miss it.

How about you? How are you using our script to better your paid search campaigns? Any suggestions or requests?

Google Analytics for Online Advertisers
Here at ROI Revolution, we consider Google Analytics tracking essential for paid search, so it's included in our PPC Campaign Management service.

Comments

PPC Whiz said:

This stuff is great! Keep up the good work team, I really appreciate you sharing this with the community. You are an excellent resource for us PPC guys out there looking to maximize our spend.
My clients will thank you!

February 14, 2008 3:25 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@PPC Whiz: Glad we could help out! Definitely keep posted here on any additions or updates, and like I said in my post, our own team will be posting some of their tips and tricks in the coming weeks.

February 14, 2008 4:22 PM

Jesse DaCosta said:

Hey Michael,

Thanks for the update, have been on the lookout for it! I've tried another method from another blog but that doesn't seem to work, at least for me, so now I've updated to the new code I'm going to test this out.

Thanks again!

February 14, 2008 4:37 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Jesse: Great! Let me know how it works for you. We're always trying to improve it.

February 14, 2008 5:54 PM

Christian Martin said:

Thanks for updating the ga.js script with this! I only saw the original change for the old urchin code yesterday after your webinar. I've already changed the GA code on both our site and looking forward to seeing the results in the coming days.

I do have a question... In the Traffic Sources::Keywords section, their are toggles for Show: total | paid | non-paid and then the Segment listbox.

On first glance, it would seem GA is providing everything without the script. Am I being simplistic in my cursory look?

Thanks again!

February 14, 2008 7:06 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Christian: Unfortunately, the Keywords report will only show you the bid terms for your paid search. Basically, it will show you the keyword phrase that you bid upon, but not the one that visitors actually typed into the search engine. Hope that makes sense.

February 15, 2008 9:32 AM

Dave Cardwell said:

Thanks for updating this script and sharing it with the community.

I'm curious - why the "UA-1" in this line of the script:
_gat._getTracker("UA-1");

February 15, 2008 11:51 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Dave: It's just a precaution, due to the way that setVar operates, and we've found that it leads to more accurate usage stats.

February 15, 2008 1:57 PM

Searchquant said:

Doesn't it seem strange that Google wouldn't make this a feature in G Analytics early on? It's clear any smart marketer's gonna want to know which queries within phrase or broad matched keywords are working and not working.

Google gets 70% of its revenue from phrase and broad match.

February 15, 2008 4:53 PM

Sonja Bakker said:

Hi,

This quiet cool. I already saw that the previous script wasn't working anymore. Going to try this one now!

February 18, 2008 11:27 AM

Julien Raby said:

Hi Michael,

thanks a lot for this new version of the script, I was using the old filter hacks but it doesn't work anymore...

One question: the script as it is now doesn't seem to work if I manually tag my link (I almost always tag my links instead of using the auto-tagging to gain more control over the utm_campaign variable...) so I was wondering if there were a quick fix fo manual link tagger like myself?

Thanks again,
Julien

February 19, 2008 6:54 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Julien: While we definitely don't recommend that you manually tag AdWords ads (it causes problems when Analytics links up the data between your two accounts), this method should work for manually tagged links, so long as those links are tagged with utm_medium=cpc and the visits are coming from a search engine with a plainly visible search query in the URL (e.g., q=search+query, p=search+query, query=search+query).

February 22, 2008 3:28 PM

Chris Bradley said:

Thanks for this, I just tried the other method last week and didn't get it to work so this comes at a great time for me but I do have one question..

Should I upload the script to my root directory?

February 24, 2008 2:41 PM

Shawn Purtell, Senior Web Analytics Engineer Author Profile Page said:

@Chris:

You can upload the file wherever you like. Most websites have a specific place where scripts are stored, but it's different for everybody. The important thing is to make sure the call to the .js script is pointing to the right place.

February 25, 2008 9:29 AM

Charles Meaden said:

The actual ga_keyword2.js script contains the following lines


var pageTracker = _gat._getTracker("UA-XXXXXX-X");

The page says not to edit the script, but should I be changing the [yoursitehere] and UA-XXXX lines so that they correspond to our tracking codes?

March 17, 2008 10:40 AM

Jeremy Aube, Director of Engineering Author Profile Page said:

@Charles: Those lines are just a re-iteration of the installation instructions as given in the article. They are just comments, so you don't need to change it.

March 18, 2008 10:48 AM

Charles Meaden said:

Jeremy,

Thank you. Two more questions if I may.

1. Does it make any difference if I have amended the code to use our details
2. Can I use remove the commented section from the ga_keyword2.js file then

March 19, 2008 6:55 AM

Jeremy Aube, Director of Engineering Author Profile Page said:

@Charles: You really shouldn't be making any changes to the javascript file. If you're just making changes to or removing the comment section, that won't affect the functionality of the script, but it would be best to leave it as is. Then anyone who looks at the script will have the version number, author, general instructions (rather than specific to a single site's setup), and when it was last modified. Any changes to the script itself could negatively affect its functionality. Michael has written this script very precisely so that it needs no modification to work with your site.

March 19, 2008 9:52 AM

Ron said:

ok, I really want to get this data from my analytics and I have upgraded to ga and installed the tracking code...but I can't for the life of me understand where I find the detailed keyword search data in my analytics account. Can someone point me in the right direction?

April 2, 2008 4:21 PM

Jeremy Aube, Director of Engineering Author Profile Page said:

@Ron: The Exact Keyword Data for the site will be in the User Defined Report. You can also segment various reports by the User Defined Variable to see this information for specific visitor traffic segments. See Michael's previous post for more information.

April 2, 2008 4:39 PM

Ron said:

So if I look in the tab "Visitor/UserDefined" and all I see under the user defined values is "not set" then it's safe to assume I screwed up in inserting the tracking code?

April 2, 2008 5:35 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Ron: Well, it either means that you screwed up, or that you don't have any paid search traffic coming into your site. The traffic has to be auto-tagged AdWords clicks or manually tagged clicks with utm_medium=cpc.

Good luck!

April 3, 2008 10:59 AM

Ryan said:

Okay, I feel like an idiot.

The code checks out fine. Analytics is otherwise tracking fine. And I am getting my adwords PPC traffic to come up.

But STILL, I'm only getting "not set".

Is there something I'm missing? Maybe something obscenely obvious?

Thanks so much!

June 3, 2008 10:06 AM

Ryan said:

Yup. I'm definitely an idiot.

1. Didn't change the .js src path.

2. Didn't upload the .js file.

June 3, 2008 10:34 AM

Eric said:

Thanks for making these scripts. I put them on my site about a week ago, and the info has been very valuable.

Unfortunately, about 50% of the data comes back as (not set) and a slightly better return of only 33% on Yahoo. I don't have my account autotagged for various reasons, but every keyword has it's own URL with utm_medium=cpc. Is this the normal capture for the script or perhaps I have done something wrong or does the order of the utm_ variables in the search string matter. Currently I set the source, medium, campaign and then the term.

Thanks again for this wonderful tool.

June 10, 2008 2:36 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Eric: Well, content network will never display a search query, and some of the search partner sites don't format the search query in the same way that Google does. 50% is about the norm for what I see.

If you can find the search network sites that your ads are running and provide them, I may be able to expand the script to use their search queries.

June 10, 2008 4:27 PM

Daniel Waisberg said:

Hi Michael,

Thank you very much for the feature it is wonderful.

I was wondering if this code can work together with the one created by John Henson from LunaMetrics: Stuff More Than One Value into GA\x92s User Defined Segment . If so, this would solve the issue of using other User Defined Variables together with it.

Thank you again.

June 22, 2008 4:05 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Daniel: I don't see why the two scripts wouldn't play nice together. :) It may require some modifications to the JavaScript. Give it a shot and let us know how it works out.

June 24, 2008 8:24 AM

Eran Malloch said:

Hi Michael,

I REALLY REALLY REALLY need this tool to work (great idea and thanks to all who developed it), but unfortunately, whenever I add it to a site created by our webdesign partners, it somehow interferes with the script that creates their drop-down menu system, and the menu system stops working... :(

This has happened on 2 seperate sites now, and obviously we have to remove your script because a non-working menu system just aint gonna cut it. ;)

I'm guessing if this is happening to me, there are probably others it is happening to as well, but perhaps they haven't bothered to contact you and mention it.

ANY help you (or anyone else reading this comment) can provide with this issue would be GREATLY appreciated. I am happy to email you the offending site urls, etc.

Thanks in advance for your time, and I really do appreciate your efforts to provide this vital tool (and bah humbug to Google for NOT providing it) ;)


Eran Malloch
WCR Internet Marketing
Perth, Western Australia

July 11, 2008 2:22 AM

wil said:

How do I create a report that shows side-by-side the keyword in the AdWords campaign that was triggered along with the user defined variable (the search term). Right now, under traffic sources, I can see one or the other.

Thanks,

Wil

July 12, 2008 2:27 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Eran: I'd check to make sure that none of the functions from the menu system interfere with the keyword script. Beyond that, I don't see why it would cause any problems. Because of the sheer number of setups and JavaScript present on websites, there's no possible way we can troubleshoot each individual issue with the script, but if you have any additional comments on precisely what is going on (error messages, etc.), then maybe we can help out.

July 21, 2008 1:29 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Wil: There is no such report, but you could create a new profile with an Advanced Filter that plugs the User Defined field into the Campaign Term field. Just cram 'em both together, and that way when you look at your keywords list, you would see:

"bid term (search term)"

This will mean that cost and click data for your AdWords Campaigns keyword report will not match up properly, thus the reason why I recommend creating an additional profile.

Hope that helps.

July 21, 2008 1:36 PM

Eric Werner said:

Hi and thanks! One quick question, what does this do?

pageTracker._initData();

This line isn't in the code that Google gave me and you didn't mention anything about it in the post so I wanted to check.

Thanks!

August 8, 2008 12:18 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Eric: pageTracker._initData() is a deprecated function that was previously required before running the Google Analytics pageTracker. You can get rid of it or keep it in; entirely up to you.

August 8, 2008 1:52 PM

Jason said:

Michael - I've modified a function in the ga_keyword2.js code that I find quite useful re: more accurate stats gathering:

function noPercent(x)
{
x = unescape(x);
x = x.replace(/\+/g," ").replace(/^\s\s*/, '').replace(/\s\s*$/, '');
return x.toLowerCase(); // added feature
}


this basically groups all upper & lower case variations so that I get an accurate picture of the number of people using a particular word or phrase. Great script!

August 14, 2008 9:44 PM

Ricky said:

I think that this script looks great, and I have just updated the script on our site to check it out.

Though one question still remains, how does this differ from the report you get out of Adwords that shows you which search results that triggered your adwords to show and generate a click?

Thanks!

August 19, 2008 8:14 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Ricky: Check out my co-worker Mark Curtis' article on the Keyword Sleuth script versus the AdWords Search Query Performance Report for the answer to your question.

August 19, 2008 10:17 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Jason: Thanks for the info. You could also use a lowercase filter inside of Google Analytics if you don't want to modify the code (if, for instance, it's already installed on your site).

August 19, 2008 10:19 AM

Eric S said:

Michael, thanks again for this wonderful script. I recently upgraded to the new tracking code and the script worked fine. Unfortunately, my 'check-out' is handled by a third party that is still running the legacy script and they are hesitant to upgrade. Note that their legacy script also has

_udn="none";
_ulink=1;

in the legacy code to enable cross-domain tracking.

So, I downgraded back to the legacy code and added the two lines for cross-domain tracking code that I had not used before, and the next day all of my User Defined Value data was missing. So I deleted the

_udn="none";
_ulink=1;

lines and it immediately returned but this left me without the cross domain tracking I had hoped to gain. Note that the User Defined Value came through just fine in the ga.js version except the link was broken across the domains due to code incompatability. Any suggestions for getting the legacy version to work cross-domain. I noticed that the slueth(); function was in the legacy code on your first blog in 07 but not the more recent blog. Might this be part of it?

On a completely separate issue, I appended the cpc search term that actually responded to the original user query to the UDV and was stunned at the level of mismatch. For example, I had a phrase/exact match bid for "word1 word2 word3 word4", the user queried the exact term "word1 word2 word3 word4" but Google responded to the query with a broad matched term "word1 word2 wordX" where wordX was barely a synonym but the price point was much higher--not to mention the ad displayed to the user's query was far less relevant because the reponse came from a different ad group. Google does this a lot.

Do you see this mis-matching to increase Search Engine revenues a lot and does your consulting service offer methods of combating this problem of what seems a lot like fraud?

August 31, 2008 8:45 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Eric S: As long as you properly tag links between domains with utmLinker, you should be fine. It should bridge the gap between domains with the right cookie information.

Good luck!

September 2, 2008 3:24 PM

Mike said:

Hi Michael,

I am on the ROI GA Online training.

I have installed the Sleuth Tracking code, but I get "(not set)" when I go check the User Defined data.

I cannot spot what I am doing wrong.

You can view my code in the source of this page:

http://www.enquete-satisfaction.com/

Thanks for your help!
Mike

October 6, 2008 9:06 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Mike: The ga_keyword2.js file must go between the first <script> section of the Google Analytics Tracking Code and the second. You have it before. Please read the article again and be sure to place it in precisely the spot that I indicated. That should fix it for you.

You also should be wary of "smart" or curled quotes showing up in your code. If you use Microsoft Outlook or Word to edit code with quotation marks and paste it into your site, you might end up with a left or a right curled quote (“ or ”) instead of a standard quote ("). Be sure to only use standard quote marks in HTML code.

October 6, 2008 11:03 AM

Mike said:

Michael,

Could it be that I had copied the code from an older version of the article?

I am asking since my code also includes Sleuth() at the end, that the new code doesn't seem to include.

Thanks for your help!
Mike

October 8, 2008 9:52 AM

Eddy said:

This is a great script that I have been using flawlessly for a while now, but for the past month or so, all the keywords within the user defined page are still attached to the Google search query that is after the q variable as in http://www.google.co.uk/search?hl=en&q=keyword1+keyword2&meta=
I dont understand why this has started happening but could do with some advice.

thanks
eddy

October 8, 2008 11:43 AM

Eddy said:

Michael, if not done so already is it possible to add the search queries for the following Google search network partners?
aolsearch.aol.co.uk
www.winbuyer.co.uk
search.babylon.com
www.kellysearch.co.uk
business.shop.ebay.co.uk
search.virginmedia.com
www.hotfroguk.co.uk
uk.ask.com
www.tiscali.co.uk
search1.sky.com
search.mywebsearch.com

there are quite a few more but they generate just one or two visits.

regards
eddy

October 8, 2008 12:35 PM

art said:

Great script. Cant wait to see the results.

October 12, 2008 10:35 PM

Mike said:

Hi Michael,

I got the script to work. However, there are 2 issues:

1) About 20-25% of the visits show as "not set" (I don't use content for that campaign, only search with Google & Search Network).

Can you tell what they could account for?

2) It's a campaign with French keywords and the script doesn't capture the accents properly (whereas GA's Traffic Sources > Keyword Report does). E.g. the word "pr\xE9vention" shows as "prévention".

Is there a way to correct that?

Thanks!
Mike

October 13, 2008 8:04 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Mike: The reason why 20-25% of your visits are "not set" is because the script currently does not account for all of the engines that are a part of the Google search network. We've been working on an update for that, which should be released in the next few days, and should reduce the percentage of "not sets".

We'll also work on getting the accents fixed. Thanks for letting me know!

October 14, 2008 10:42 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Eddy: I'm not really sure what you mean by this. Can you illustrate with a screenshot or a URL?

October 14, 2008 10:45 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Eddy: I've been working on the script, trying to increase the number of search engine query parameters that it recognizes. Thanks for your list, and look for an update over the next few days.

October 14, 2008 10:46 AM

art said:

Great tool! I have started to see the results and they are amazing. 80% of my visits are showing as "not set". Are they all as a results of google parters not being included or because I haven't set utm_medium=ppc for both yahoo and msn ppc traffic? the interesting part is the bulk of our revenue is coming from google partners/or the other engines...the "not set" portion.

Second question..I want to add another domain which is an add-on to the main domain..Do I follow the exact steps for additional domains.

October 15, 2008 12:42 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Art: It could be because you haven't set utm_medium=cpc for Yahoo! and MSN paid traffic. Many Google partners aren't included yet, either, but I'll be posting an update to the script that will contain more of those partners. Keep an eye out on the blog, or subscribe to it to keep up-to-date.

October 15, 2008 10:26 AM

Clikckbank Affiliates said:

Thanks for the update...

October 20, 2008 3:14 PM

Moses Chang said:

Hi, just stumbled upon this tool and immediately created a new Google Analytics account for our website and installed it. Do I lose the ability to track AdWords Campaigns (under the Traffic Sources tab in Google Analytics) once this tool is installed? I also can't find where the search query info are being displayed...

Thanks in advance,
Moses

October 22, 2008 10:46 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Moses: This won't affect your AdWords Campaigns report and won't take away your ability to track campaigns, adgroups, or keywords. To access the exact keyword information, you can either drill down to a specific campaign/adgroup/keyword in the Traffic Sources > AdWords > AdWords Campaigns report and use the Dimension User Defined dropdown.

You can also view all of your exact keyword combinations using the Visitors > User Defined report.

October 22, 2008 11:01 AM

Aidin said:

How does this differ from the filter hack? Which one is better?

November 4, 2008 6:04 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Aidin: Check out my first article when I first created the script for how it differs from Omega's filter hack. I like the script better for the reasons outlined there.

November 5, 2008 1:32 PM

Gavin Doolan said:

Hi there,
I wonder if its possible to concatenate search queries to the user defined value to see data before the last click. (preventing a last click wins scenario)

What I mean is see the string of keywords used before a purchase. Say during the buyer research phase, till the point of purchase?

Obviously there is also the issue of previous campaigns which triggered a visit such as banner / email but I figured this may be the place to mention such an idea.

I've only just started to learn JS myself, perhaps by the time I'm finished reading my current book I'll have an idea on how to do it myself.

Cheers,
Gavin.

November 12, 2008 5:00 AM

Mike said:

Hello Michael,

Are you aware of this Advanced Filter setup that shows the bid keyword + exact search query?

http://www.ga-experts.com/blog/2006/11/how-to-get-detailed-ppc-keyword-data-from-google-analytics/

If so can you comment on the advantages/disadvantages of yours vs. theirs?

One thing that comes to mind is that theirs leaves the User Defined variable free for another utilization.

Thanks!
Mike

November 18, 2008 4:05 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Gavin: It's definitely possible. We've been working on something very similar here. Good luck on your own JS pursuits! Let us know if you post something about this elsewhere and we'll be sure to give you some link love.

November 19, 2008 3:11 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Mike: Definitely. It was Brian's filter that inspired me. The only issue I had with their is how it works on return visits to sites. See my original article for a full explanation.

November 19, 2008 3:13 PM

Aidin said:

Is there a way to implement this script to another profile?The first profile is already using the user defined field by live person chat. Could the two coexist within the same profile?

November 26, 2008 4:03 PM

Bud Gibson said:

How does this play with something like advanced segmentation? I was looking at those reports, and they seem to show what percentage of your search traffic for a given keyword is from paid sources.

The one thing I can see is that I might be able to see how my keywords are broad matching to actual search terms.

December 9, 2008 8:36 AM

Amit said:

Hi Michael,

Awesome post!
I was wondering if combining all the javascript in to a single .js file would be ok?

ON THE WEBPAGE YOUR WOULD PUT:

THE CONTENTS ON MyGA.js WOULD LOOK AS FOLLOWS:

var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));

function noPercent(x)
{
x = unescape(x);
return x.replace(/\+/g," ").replace(/^\s\s*/, '').replace(/\s\s*$/, '');
}

function getRef()
{
ref = document.referrer;
re = /(\?|&)(q|p|query|encquery|qt|terms|rdata|qs|wd|text|szukaj|k|searchExpr|
search_for|string|search_query|searchfor)=([^&]+)/;
searchq = re.exec(ref);
if(searchq) {
searchq[3] = noPercent(searchq[3]);
sleuthTracker._setVar(searchq[3]);
}
else {
sleuthTracker._setVar('Referral: ' + document.referrer);
}
}

function sleuth()
{
if(document.location.search.indexOf("gclid")!=-1||
document.location.search.indexOf("cpc")!=-1) {
getRef();
}
}

var sleuthTracker = _gat._getTracker("UA-1");
sleuthTracker._initData();
sleuth();

var pageTracker = _gat._getTracker("UA-XXXXXX-1");
pageTracker._initData();
pageTracker._trackPageview();

December 24, 2008 4:45 AM

Amit said:

no worries, I figured out why they need to be seperate. Thanks!

December 24, 2008 5:16 AM

rookie said:

The script works great!!
Can somebody help me to modify the script to append the ip of the user next to the search string? This would be invaluable for our statistical analysis. Unfortunately my javascript knowledge is limited. Thanks in advance!

January 4, 2009 6:22 PM

Bud Gibson said:

I just installed this script. An observation: why didn't you name space it? That would eliminate almost all possibilities of javascript conflict which I noticed one commenter remarking. I may do that myself if I get some spare time. It just involves encapsulating your functions in an object with a particular name. You then access the functions with Object.functionName().

January 7, 2009 10:37 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Amit: Yep, there's a reason why they're separate, though you can wrangle the JavaScript in such a way that there's only a single reference for all Google Analytics code, if you wanted to.

January 29, 2009 1:37 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@rookie: Glad the script is working for you!

As pulling IP addresses into Google Analytics actually violates the terms and conditions (and is impossible to do with JavaScript alone), there are currently no plans to add this functionality to the script.

January 29, 2009 1:43 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Bud: We have been testing a version of this script internally that expands on the features and uses object-oriented coding, but you're welcome to post your own.

January 29, 2009 1:50 PM

satin jain said:

but where i put this code..

i m new about this stuff...

please tell me where i have two put this script ...

please tell me...

February 13, 2009 2:55 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@satin jain: Just replace the exiting Google Analytics code, wherever it is on the page, with the one in the box.

February 13, 2009 3:17 PM

Brian Kaldenberg said:

I have installed everything and it appears to be tracking exact keywords correctly.

Problem is when inside analytics if I click the "clicks" tab, none of the clicks, impressions, ctr, cost, etc. data is showing up for dimension user-defined.

I have auto-link tag set to on.

Clicks data shows up for my broad match adgroup, but isn't the point of exact keyword tracking to be able to see clicks data for exact keywords within broad match?

I sure hope it is possible.

February 27, 2009 1:58 AM

Nikki said:

Hi

Is there a way of relating the keyword input to the keyword bid on? e.g. a hybrid of yours and Brian Cliftons PPC terms methods (his override bid term filter). So that a client can see e.g. car parking (car+parking+greater+manchester) using the ga2.js file?

Thanks
Nikki

March 16, 2009 8:54 AM

Richie Rich said:

Hi Michael. I have been successfully using the code here on 6 PPC accounts and the information has proved invaluable - thx so much for this.
However today on 2 of my 6 accounts I have no adwords data showing in my analytics? (and therefor no excat keyword tracking. Have you experienced this before - it may very well be an adwords glitch? Any ideas?

March 25, 2009 8:26 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Richie: No idea why it's not working. Have you checked to make sure that your AdWords linking and cost data is all set up properly?

March 25, 2009 3:20 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Nikki: It seems like it would be possible using filters. Give it a go and let us know how it works out.

March 25, 2009 3:24 PM

Medela Dude said:

Hi Mike, appreciate your work on this and have been using it for a year or 2 now.

Any news on a resolution to the "Not Set" issue?

May 6, 2009 10:51 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Medela Dude: Not yet. There's just a lot of traffic from Google that doesn't match the standard query. We'll definitely keep everyone posted with any updates to the code. Be sure to add the ROI blog to your reader of choice or subscribe via email with the link at the top right.

May 6, 2009 2:27 PM

Salman said:

I have implemented the script. Works fine. It returns the actual KWs in the user defined reports, however there is no goal conversions associated with these KWs although i know that i have made conversions through these KWs.

May 15, 2009 12:17 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Salman: Try drilling down to the keyword level in the Keywords report where you should see your conversions. Then segment by User Defined. What do you see?

May 15, 2009 9:57 AM

Neal said:

Michael, does this keyword filter affect GA ecommerce data? I recently installed it in one of my sites...I see the specific queries from Adwords but don't see conversion data. Our overall ecommerce stats also show $0 revenue right after installing the GA code.

June 19, 2009 7:39 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Neal: It shouldn't affect ecommerce data. What happens when you remove it?

June 22, 2009 11:53 AM

Neal said:

Michael,

We installed the code and all ecommerce data stopped reporting. We were averaging several $30,000 in revenue per day and then it went to $0 after we changed the GA code. Any ideas?

June 24, 2009 9:57 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Neal: Have you tried using the Exact Keyword Tracking script on all pages but your receipt page?

June 25, 2009 4:58 PM

Vince said:

Can someone explain how we can embed this data into our Website forms so the search keywords and PPC data is added to our leads please?

Basically, trying to achieve the same as what Salesforce.com Google adwords integration has with their web-to-lead form.
http://www.semgeek.com/semgeek/2008/03/what-you-need-t.html

July 18, 2009 9:49 AM

neal@akamaiseo.com said:


Michael, are you saying that the modified GA script needs to be on every page of your site except for your confirmation/receipt page?

July 20, 2009 3:51 PM

afzal hanif said:

Really great post, thanx. Right now i'm using the alternate 'filter method' to show the true keywords, however, conversions are still only attributed to the original (adwords) keyword. Perhaps I overlooked, but will this javascript method also show conversions to the true keywords? Hope you can help me, thanx:)

August 6, 2009 3:55 AM

afzal hanif said:

Nice post. I have been using the alternate mode now for a while, but one issue with this: conversions are not attributed to the 'true keywords', but to the keyword defined in adwords. Will this method show actual conversions to the true keywords? Perhaps I missed it but thanx in advance:)!

August 11, 2009 10:44 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Afzal: Yes, it will. One benefit it has over the other method. Just be sure to use the user defined report.

August 19, 2009 10:22 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Neal: Technically it should be on every possible landing page. You can write conditional JavaScript to check and see whether or not this is this case, or you can just put it on every page. Either way works, really.

August 19, 2009 10:32 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Vince: That's a bit more complicated. Justin Cutroni has detailed a method for something similar at his blog. Hope it helps!

August 19, 2009 10:36 AM

Jen said:

thanks Michael and ROIRev. This one gave us substantial savings over a twelve month period.

September 4, 2009 4:51 AM

Guy said:

Great stuff!!
Any way to fix it to show utf-8 keywords?

October 9, 2009 11:26 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Guy: To be honest, I haven't spent a lot of time working on the script. If you'd like to add decoding for utf-8, please feel free! Just let us know of any updates so we can share the wealth.

October 9, 2009 1:24 PM

Riedel Wine Glass said:

So should this script be on every page in the website? sorry newbie question

December 22, 2009 3:18 PM

Wytze said:

Thanks a million Michael,

Your script has made our year! Like somebody else mentioned earlier. This information is invaluable! Only running for a couple of days and I've already seen so many incorrect queries!

I do have a question though, is there a way to associate costs to the queries like you see with Search Query reports in Adwords?

Thanks again so much and have an early merry christmas! :)

December 23, 2009 7:00 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Riedel: Yes, put it on every page of your site. It should replace the standard Google Analytics Tracking Code.

January 4, 2010 5:55 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Wytze: No, there's not currently a way to associate costs with the queries. We typically just use the SQR in AdWords to do that.

January 4, 2010 5:57 PM

David Ogletree said:

I used to work at a ppc agency and our Google rep gave me a filter that let me track search partners. I did not save the filter and I don't have access to that account anymore. I can't seem to find how to do this again. Can you make a filter that does this?

January 12, 2010 9:46 AM

GregBB said:

What would be the reasons to favor the ga.js update to view actual search phrases in comparison to applying the "Override Bid Term" filters? Is the result the same? One obvious reason is that you can instantly apply it to all profiles, which could also be a disincentive if you would like to have more flexibility. Would appreciate your thoughts. Thanks!

February 4, 2010 8:01 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@David: You can add a query parameter to your destination URLs and then use the special AdWords macro {placement} to insert the URL that the ad was displayed on, like so:

www.mysite.com?site={placement}

Then you can use something like Filters, Site Search or Custom Variables to pull that data out and put it into a Google Analytics report.

March 6, 2010 4:18 PM

Kevin Joyner said:

Hi Michael

I seem to have gathered the impression from somewhere that there are plans ultimately to deprecate the GA user defined variable, and that we should use custom variables where possible.

Would it be worthwhile to adapt your Keyword Sleuth script to use custom variables? If so, I don't suppose you've done that, have you? :-)

Many thanks

Kevin

April 20, 2010 9:00 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Kevin: We have, and it works just fine. Look for an article about it in the near future.

April 20, 2010 11:10 AM

Sandra said:

Ok...pardon the moron. I have read this entire thread and just want to make sure I understand completely b4 I implement the code.

1. I literally just REPLACE the code on my sites with the one up top u provide (obviously changing the profile numbers)?

2. Do I have to also upload this ga_keyword2.js file? If so, why?

Thanks so much - really looking 4ward to taking it for a test drive!

S

May 19, 2010 3:55 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Sandra: Yes, replace the code on your site with the one above. And, yes, you do need to upload the file. Why? Because that's where all the code that grabs the search query is.

May 25, 2010 9:42 AM

Eric said:

Hi Michael,

I wanted to thank you for this wonderful tool. We've been using it for almost 2 years and its benefit has been significant.

Yesterday, I upgraded my site to the new asynchronous GATC code but wasn't quite sure how to integrate ga_keyword.js so I took my best shot as shown below. No luck--the user defined value data has disappeared.

Actually, there are two problems here. Whenever I originally set up the 'traditional' GATC code with the two additional lines for cross-domain tracking, the UDV info would disappeared. We decided knowing what the original queries were outweighed cross domain tracking so we just left out the

pageTracker._setDomainName('none');
pageTracker._setAllowLinker(true);

lines and lived with the compromise. This time I included the asynchronous equivalent for cross domain hoping it would work but no luck.

_gaq.push(['_setDomainName', 'none']);
_gaq.push(['_setAllowLinker', true]);

So I've changed too many variables to know what the real problem is, but if this is a no-brainer for you, would you please point out my error. Alternately, I can go back and remove the cross domain asynchronous lines to try and isolate the cause and effect and see what happens.

Also noticed an early post about deprecating the _setVar() function and an upcoming post about that? Perhaps that post might be nearby?

Would be grateful for any help.

Eric.

Current Attempt:

<!--
<head>

<script src="ga_keyword.js" type="text/javascript"></script>

<script type="text/javascript">

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-123456-1']);

_gaq.push(['_setDomainName', 'none']);
_gaq.push(['_setAllowLinker', true]);

_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

</script>

</head>
-->

July 7, 2010 9:00 AM

Darrell said:

Google Adwords lets me generate a report of keyphrases typed that caused ads to show up and wheter they generated clicks or not. These are phrases typed during the search, including searches on other sites, not just the keyword that match the ad. I can then see phrases generating clicks that I don't like the words that are in them, then ad those to my negative keywords. Is this something new that was not available in 2008 when this ga_keyword script was created?

September 8, 2010 5:52 PM

George Strait Tickets said:

Then you can use something like Filters, Site Search or Custom Variables to pull that data out and put it into a Google Analytics report.

September 23, 2010 5:58 AM

Christina said:

I used to work at a ppc agency and our Google rep gave me a filter that let me track search partners. I did not save the filter and I don't have access to that account anymore. I can't seem to find how to do this again. Can you make a filter that does this

October 26, 2010 8:58 AM

PPC Whiz said:

This stuff is great! Keep up the good work team, I really appreciate you sharing this with the community. You are an excellent resource for us PPC guys out there looking to maximize our spend.
My clients will thank you!

February 14, 2008 3:25 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@PPC Whiz: Glad we could help out! Definitely keep posted here on any additions or updates, and like I said in my post, our own team will be posting some of their tips and tricks in the coming weeks.

February 14, 2008 4:22 PM

Jesse DaCosta said:

Hey Michael,

Thanks for the update, have been on the lookout for it! I've tried another method from another blog but that doesn't seem to work, at least for me, so now I've updated to the new code I'm going to test this out.

Thanks again!

February 14, 2008 4:37 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Jesse: Great! Let me know how it works for you. We're always trying to improve it.

February 14, 2008 5:54 PM

Christian Martin said:

Thanks for updating the ga.js script with this! I only saw the original change for the old urchin code yesterday after your webinar. I've already changed the GA code on both our site and looking forward to seeing the results in the coming days.

I do have a question... In the Traffic Sources::Keywords section, their are toggles for Show: total | paid | non-paid and then the Segment listbox.

On first glance, it would seem GA is providing everything without the script. Am I being simplistic in my cursory look?

Thanks again!

February 14, 2008 7:06 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Christian: Unfortunately, the Keywords report will only show you the bid terms for your paid search. Basically, it will show you the keyword phrase that you bid upon, but not the one that visitors actually typed into the search engine. Hope that makes sense.

February 15, 2008 9:32 AM

Dave Cardwell said:

Thanks for updating this script and sharing it with the community.

I'm curious - why the "UA-1" in this line of the script:
_gat._getTracker("UA-1");

February 15, 2008 11:51 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Dave: It's just a precaution, due to the way that setVar operates, and we've found that it leads to more accurate usage stats.

February 15, 2008 1:57 PM

Searchquant said:

Doesn't it seem strange that Google wouldn't make this a feature in G Analytics early on? It's clear any smart marketer's gonna want to know which queries within phrase or broad matched keywords are working and not working.

Google gets 70% of its revenue from phrase and broad match.

February 15, 2008 4:53 PM

Sonja Bakker said:

Hi,

This quiet cool. I already saw that the previous script wasn't working anymore. Going to try this one now!

February 18, 2008 11:27 AM

Julien Raby said:

Hi Michael,

thanks a lot for this new version of the script, I was using the old filter hacks but it doesn't work anymore...

One question: the script as it is now doesn't seem to work if I manually tag my link (I almost always tag my links instead of using the auto-tagging to gain more control over the utm_campaign variable...) so I was wondering if there were a quick fix fo manual link tagger like myself?

Thanks again,
Julien

February 19, 2008 6:54 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Julien: While we definitely don't recommend that you manually tag AdWords ads (it causes problems when Analytics links up the data between your two accounts), this method should work for manually tagged links, so long as those links are tagged with utm_medium=cpc and the visits are coming from a search engine with a plainly visible search query in the URL (e.g., q=search+query, p=search+query, query=search+query).

February 22, 2008 3:28 PM

Chris Bradley said:

Thanks for this, I just tried the other method last week and didn't get it to work so this comes at a great time for me but I do have one question..

Should I upload the script to my root directory?

February 24, 2008 2:41 PM

Shawn Purtell, Senior Web Analytics Engineer Author Profile Page said:

@Chris:

You can upload the file wherever you like. Most websites have a specific place where scripts are stored, but it's different for everybody. The important thing is to make sure the call to the .js script is pointing to the right place.

February 25, 2008 9:29 AM

Charles Meaden said:

The actual ga_keyword2.js script contains the following lines


var pageTracker = _gat._getTracker("UA-XXXXXX-X");

The page says not to edit the script, but should I be changing the [yoursitehere] and UA-XXXX lines so that they correspond to our tracking codes?

March 17, 2008 10:40 AM

Jeremy Aube, Director of Engineering Author Profile Page said:

@Charles: Those lines are just a re-iteration of the installation instructions as given in the article. They are just comments, so you don't need to change it.

March 18, 2008 10:48 AM

Charles Meaden said:

Jeremy,

Thank you. Two more questions if I may.

1. Does it make any difference if I have amended the code to use our details
2. Can I use remove the commented section from the ga_keyword2.js file then

March 19, 2008 6:55 AM

Jeremy Aube, Director of Engineering Author Profile Page said:

@Charles: You really shouldn't be making any changes to the javascript file. If you're just making changes to or removing the comment section, that won't affect the functionality of the script, but it would be best to leave it as is. Then anyone who looks at the script will have the version number, author, general instructions (rather than specific to a single site's setup), and when it was last modified. Any changes to the script itself could negatively affect its functionality. Michael has written this script very precisely so that it needs no modification to work with your site.

March 19, 2008 9:52 AM

Ron said:

ok, I really want to get this data from my analytics and I have upgraded to ga and installed the tracking code...but I can't for the life of me understand where I find the detailed keyword search data in my analytics account. Can someone point me in the right direction?

April 2, 2008 4:21 PM

Jeremy Aube, Director of Engineering Author Profile Page said:

@Ron: The Exact Keyword Data for the site will be in the User Defined Report. You can also segment various reports by the User Defined Variable to see this information for specific visitor traffic segments. See Michael's previous post for more information.

April 2, 2008 4:39 PM

Ron said:

So if I look in the tab "Visitor/UserDefined" and all I see under the user defined values is "not set" then it's safe to assume I screwed up in inserting the tracking code?

April 2, 2008 5:35 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Ron: Well, it either means that you screwed up, or that you don't have any paid search traffic coming into your site. The traffic has to be auto-tagged AdWords clicks or manually tagged clicks with utm_medium=cpc.

Good luck!

April 3, 2008 10:59 AM

Ryan said:

Okay, I feel like an idiot.

The code checks out fine. Analytics is otherwise tracking fine. And I am getting my adwords PPC traffic to come up.

But STILL, I'm only getting "not set".

Is there something I'm missing? Maybe something obscenely obvious?

Thanks so much!

June 3, 2008 10:06 AM

Ryan said:

Yup. I'm definitely an idiot.

1. Didn't change the .js src path.

2. Didn't upload the .js file.

June 3, 2008 10:34 AM

Eric said:

Thanks for making these scripts. I put them on my site about a week ago, and the info has been very valuable.

Unfortunately, about 50% of the data comes back as (not set) and a slightly better return of only 33% on Yahoo. I don't have my account autotagged for various reasons, but every keyword has it's own URL with utm_medium=cpc. Is this the normal capture for the script or perhaps I have done something wrong or does the order of the utm_ variables in the search string matter. Currently I set the source, medium, campaign and then the term.

Thanks again for this wonderful tool.

June 10, 2008 2:36 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Eric: Well, content network will never display a search query, and some of the search partner sites don't format the search query in the same way that Google does. 50% is about the norm for what I see.

If you can find the search network sites that your ads are running and provide them, I may be able to expand the script to use their search queries.

June 10, 2008 4:27 PM

Daniel Waisberg said:

Hi Michael,

Thank you very much for the feature it is wonderful.

I was wondering if this code can work together with the one created by John Henson from LunaMetrics: Stuff More Than One Value into GA\x92s User Defined Segment . If so, this would solve the issue of using other User Defined Variables together with it.

Thank you again.

June 22, 2008 4:05 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Daniel: I don't see why the two scripts wouldn't play nice together. :) It may require some modifications to the JavaScript. Give it a shot and let us know how it works out.

June 24, 2008 8:24 AM

Eran Malloch said:

Hi Michael,

I REALLY REALLY REALLY need this tool to work (great idea and thanks to all who developed it), but unfortunately, whenever I add it to a site created by our webdesign partners, it somehow interferes with the script that creates their drop-down menu system, and the menu system stops working... :(

This has happened on 2 seperate sites now, and obviously we have to remove your script because a non-working menu system just aint gonna cut it. ;)

I'm guessing if this is happening to me, there are probably others it is happening to as well, but perhaps they haven't bothered to contact you and mention it.

ANY help you (or anyone else reading this comment) can provide with this issue would be GREATLY appreciated. I am happy to email you the offending site urls, etc.

Thanks in advance for your time, and I really do appreciate your efforts to provide this vital tool (and bah humbug to Google for NOT providing it) ;)


Eran Malloch
WCR Internet Marketing
Perth, Western Australia

July 11, 2008 2:22 AM

wil said:

How do I create a report that shows side-by-side the keyword in the AdWords campaign that was triggered along with the user defined variable (the search term). Right now, under traffic sources, I can see one or the other.

Thanks,

Wil

July 12, 2008 2:27 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Eran: I'd check to make sure that none of the functions from the menu system interfere with the keyword script. Beyond that, I don't see why it would cause any problems. Because of the sheer number of setups and JavaScript present on websites, there's no possible way we can troubleshoot each individual issue with the script, but if you have any additional comments on precisely what is going on (error messages, etc.), then maybe we can help out.

July 21, 2008 1:29 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Wil: There is no such report, but you could create a new profile with an Advanced Filter that plugs the User Defined field into the Campaign Term field. Just cram 'em both together, and that way when you look at your keywords list, you would see:

"bid term (search term)"

This will mean that cost and click data for your AdWords Campaigns keyword report will not match up properly, thus the reason why I recommend creating an additional profile.

Hope that helps.

July 21, 2008 1:36 PM

Eric Werner said:

Hi and thanks! One quick question, what does this do?

pageTracker._initData();

This line isn't in the code that Google gave me and you didn't mention anything about it in the post so I wanted to check.

Thanks!

August 8, 2008 12:18 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Eric: pageTracker._initData() is a deprecated function that was previously required before running the Google Analytics pageTracker. You can get rid of it or keep it in; entirely up to you.

August 8, 2008 1:52 PM

Jason said:

Michael - I've modified a function in the ga_keyword2.js code that I find quite useful re: more accurate stats gathering:

function noPercent(x)
{
x = unescape(x);
x = x.replace(/\+/g," ").replace(/^\s\s*/, '').replace(/\s\s*$/, '');
return x.toLowerCase(); // added feature
}


this basically groups all upper & lower case variations so that I get an accurate picture of the number of people using a particular word or phrase. Great script!

August 14, 2008 9:44 PM

Ricky said:

I think that this script looks great, and I have just updated the script on our site to check it out.

Though one question still remains, how does this differ from the report you get out of Adwords that shows you which search results that triggered your adwords to show and generate a click?

Thanks!

August 19, 2008 8:14 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Ricky: Check out my co-worker Mark Curtis' article on the Keyword Sleuth script versus the AdWords Search Query Performance Report for the answer to your question.

August 19, 2008 10:17 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Jason: Thanks for the info. You could also use a lowercase filter inside of Google Analytics if you don't want to modify the code (if, for instance, it's already installed on your site).

August 19, 2008 10:19 AM

Eric S said:

Michael, thanks again for this wonderful script. I recently upgraded to the new tracking code and the script worked fine. Unfortunately, my 'check-out' is handled by a third party that is still running the legacy script and they are hesitant to upgrade. Note that their legacy script also has

_udn="none";
_ulink=1;

in the legacy code to enable cross-domain tracking.

So, I downgraded back to the legacy code and added the two lines for cross-domain tracking code that I had not used before, and the next day all of my User Defined Value data was missing. So I deleted the

_udn="none";
_ulink=1;

lines and it immediately returned but this left me without the cross domain tracking I had hoped to gain. Note that the User Defined Value came through just fine in the ga.js version except the link was broken across the domains due to code incompatability. Any suggestions for getting the legacy version to work cross-domain. I noticed that the slueth(); function was in the legacy code on your first blog in 07 but not the more recent blog. Might this be part of it?

On a completely separate issue, I appended the cpc search term that actually responded to the original user query to the UDV and was stunned at the level of mismatch. For example, I had a phrase/exact match bid for "word1 word2 word3 word4", the user queried the exact term "word1 word2 word3 word4" but Google responded to the query with a broad matched term "word1 word2 wordX" where wordX was barely a synonym but the price point was much higher--not to mention the ad displayed to the user's query was far less relevant because the reponse came from a different ad group. Google does this a lot.

Do you see this mis-matching to increase Search Engine revenues a lot and does your consulting service offer methods of combating this problem of what seems a lot like fraud?

August 31, 2008 8:45 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Eric S: As long as you properly tag links between domains with utmLinker, you should be fine. It should bridge the gap between domains with the right cookie information.

Good luck!

September 2, 2008 3:24 PM

Mike said:

Hi Michael,

I am on the ROI GA Online training.

I have installed the Sleuth Tracking code, but I get "(not set)" when I go check the User Defined data.

I cannot spot what I am doing wrong.

You can view my code in the source of this page:

http://www.enquete-satisfaction.com/

Thanks for your help!
Mike

October 6, 2008 9:06 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Mike: The ga_keyword2.js file must go between the first <script> section of the Google Analytics Tracking Code and the second. You have it before. Please read the article again and be sure to place it in precisely the spot that I indicated. That should fix it for you.

You also should be wary of "smart" or curled quotes showing up in your code. If you use Microsoft Outlook or Word to edit code with quotation marks and paste it into your site, you might end up with a left or a right curled quote (“ or ”) instead of a standard quote ("). Be sure to only use standard quote marks in HTML code.

October 6, 2008 11:03 AM

Mike said:

Michael,

Could it be that I had copied the code from an older version of the article?

I am asking since my code also includes Sleuth() at the end, that the new code doesn't seem to include.

Thanks for your help!
Mike

October 8, 2008 9:52 AM

Eddy said:

This is a great script that I have been using flawlessly for a while now, but for the past month or so, all the keywords within the user defined page are still attached to the Google search query that is after the q variable as in http://www.google.co.uk/search?hl=en&q=keyword1+keyword2&meta=
I dont understand why this has started happening but could do with some advice.

thanks
eddy

October 8, 2008 11:43 AM

Eddy said:

Michael, if not done so already is it possible to add the search queries for the following Google search network partners?
aolsearch.aol.co.uk
www.winbuyer.co.uk
search.babylon.com
www.kellysearch.co.uk
business.shop.ebay.co.uk
search.virginmedia.com
www.hotfroguk.co.uk
uk.ask.com
www.tiscali.co.uk
search1.sky.com
search.mywebsearch.com

there are quite a few more but they generate just one or two visits.

regards
eddy

October 8, 2008 12:35 PM

art said:

Great script. Cant wait to see the results.

October 12, 2008 10:35 PM

Mike said:

Hi Michael,

I got the script to work. However, there are 2 issues:

1) About 20-25% of the visits show as "not set" (I don't use content for that campaign, only search with Google & Search Network).

Can you tell what they could account for?

2) It's a campaign with French keywords and the script doesn't capture the accents properly (whereas GA's Traffic Sources > Keyword Report does). E.g. the word "pr\xE9vention" shows as "prévention".

Is there a way to correct that?

Thanks!
Mike

October 13, 2008 8:04 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Mike: The reason why 20-25% of your visits are "not set" is because the script currently does not account for all of the engines that are a part of the Google search network. We've been working on an update for that, which should be released in the next few days, and should reduce the percentage of "not sets".

We'll also work on getting the accents fixed. Thanks for letting me know!

October 14, 2008 10:42 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Eddy: I'm not really sure what you mean by this. Can you illustrate with a screenshot or a URL?

October 14, 2008 10:45 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Eddy: I've been working on the script, trying to increase the number of search engine query parameters that it recognizes. Thanks for your list, and look for an update over the next few days.

October 14, 2008 10:46 AM

art said:

Great tool! I have started to see the results and they are amazing. 80% of my visits are showing as "not set". Are they all as a results of google parters not being included or because I haven't set utm_medium=ppc for both yahoo and msn ppc traffic? the interesting part is the bulk of our revenue is coming from google partners/or the other engines...the "not set" portion.

Second question..I want to add another domain which is an add-on to the main domain..Do I follow the exact steps for additional domains.

October 15, 2008 12:42 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Art: It could be because you haven't set utm_medium=cpc for Yahoo! and MSN paid traffic. Many Google partners aren't included yet, either, but I'll be posting an update to the script that will contain more of those partners. Keep an eye out on the blog, or subscribe to it to keep up-to-date.

October 15, 2008 10:26 AM

Clikckbank Affiliates said:

Thanks for the update...

October 20, 2008 3:14 PM

Moses Chang said:

Hi, just stumbled upon this tool and immediately created a new Google Analytics account for our website and installed it. Do I lose the ability to track AdWords Campaigns (under the Traffic Sources tab in Google Analytics) once this tool is installed? I also can't find where the search query info are being displayed...

Thanks in advance,
Moses

October 22, 2008 10:46 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Moses: This won't affect your AdWords Campaigns report and won't take away your ability to track campaigns, adgroups, or keywords. To access the exact keyword information, you can either drill down to a specific campaign/adgroup/keyword in the Traffic Sources > AdWords > AdWords Campaigns report and use the Dimension User Defined dropdown.

You can also view all of your exact keyword combinations using the Visitors > User Defined report.

October 22, 2008 11:01 AM

Aidin said:

How does this differ from the filter hack? Which one is better?

November 4, 2008 6:04 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Aidin: Check out my first article when I first created the script for how it differs from Omega's filter hack. I like the script better for the reasons outlined there.

November 5, 2008 1:32 PM

Gavin Doolan said:

Hi there,
I wonder if its possible to concatenate search queries to the user defined value to see data before the last click. (preventing a last click wins scenario)

What I mean is see the string of keywords used before a purchase. Say during the buyer research phase, till the point of purchase?

Obviously there is also the issue of previous campaigns which triggered a visit such as banner / email but I figured this may be the place to mention such an idea.

I've only just started to learn JS myself, perhaps by the time I'm finished reading my current book I'll have an idea on how to do it myself.

Cheers,
Gavin.

November 12, 2008 5:00 AM

Mike said:

Hello Michael,

Are you aware of this Advanced Filter setup that shows the bid keyword + exact search query?

http://www.ga-experts.com/blog/2006/11/how-to-get-detailed-ppc-keyword-data-from-google-analytics/

If so can you comment on the advantages/disadvantages of yours vs. theirs?

One thing that comes to mind is that theirs leaves the User Defined variable free for another utilization.

Thanks!
Mike

November 18, 2008 4:05 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Gavin: It's definitely possible. We've been working on something very similar here. Good luck on your own JS pursuits! Let us know if you post something about this elsewhere and we'll be sure to give you some link love.

November 19, 2008 3:11 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Mike: Definitely. It was Brian's filter that inspired me. The only issue I had with their is how it works on return visits to sites. See my original article for a full explanation.

November 19, 2008 3:13 PM

Aidin said:

Is there a way to implement this script to another profile?The first profile is already using the user defined field by live person chat. Could the two coexist within the same profile?

November 26, 2008 4:03 PM

Bud Gibson said:

How does this play with something like advanced segmentation? I was looking at those reports, and they seem to show what percentage of your search traffic for a given keyword is from paid sources.

The one thing I can see is that I might be able to see how my keywords are broad matching to actual search terms.

December 9, 2008 8:36 AM

Amit said:

Hi Michael,

Awesome post!
I was wondering if combining all the javascript in to a single .js file would be ok?

ON THE WEBPAGE YOUR WOULD PUT:

THE CONTENTS ON MyGA.js WOULD LOOK AS FOLLOWS:

var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));

function noPercent(x)
{
x = unescape(x);
return x.replace(/\+/g," ").replace(/^\s\s*/, '').replace(/\s\s*$/, '');
}

function getRef()
{
ref = document.referrer;
re = /(\?|&)(q|p|query|encquery|qt|terms|rdata|qs|wd|text|szukaj|k|searchExpr|
search_for|string|search_query|searchfor)=([^&]+)/;
searchq = re.exec(ref);
if(searchq) {
searchq[3] = noPercent(searchq[3]);
sleuthTracker._setVar(searchq[3]);
}
else {
sleuthTracker._setVar('Referral: ' + document.referrer);
}
}

function sleuth()
{
if(document.location.search.indexOf("gclid")!=-1||
document.location.search.indexOf("cpc")!=-1) {
getRef();
}
}

var sleuthTracker = _gat._getTracker("UA-1");
sleuthTracker._initData();
sleuth();

var pageTracker = _gat._getTracker("UA-XXXXXX-1");
pageTracker._initData();
pageTracker._trackPageview();

December 24, 2008 4:45 AM

Amit said:

no worries, I figured out why they need to be seperate. Thanks!

December 24, 2008 5:16 AM

rookie said:

The script works great!!
Can somebody help me to modify the script to append the ip of the user next to the search string? This would be invaluable for our statistical analysis. Unfortunately my javascript knowledge is limited. Thanks in advance!

January 4, 2009 6:22 PM

Bud Gibson said:

I just installed this script. An observation: why didn't you name space it? That would eliminate almost all possibilities of javascript conflict which I noticed one commenter remarking. I may do that myself if I get some spare time. It just involves encapsulating your functions in an object with a particular name. You then access the functions with Object.functionName().

January 7, 2009 10:37 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Amit: Yep, there's a reason why they're separate, though you can wrangle the JavaScript in such a way that there's only a single reference for all Google Analytics code, if you wanted to.

January 29, 2009 1:37 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@rookie: Glad the script is working for you!

As pulling IP addresses into Google Analytics actually violates the terms and conditions (and is impossible to do with JavaScript alone), there are currently no plans to add this functionality to the script.

January 29, 2009 1:43 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Bud: We have been testing a version of this script internally that expands on the features and uses object-oriented coding, but you're welcome to post your own.

January 29, 2009 1:50 PM

satin jain said:

but where i put this code..

i m new about this stuff...

please tell me where i have two put this script ...

please tell me...

February 13, 2009 2:55 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@satin jain: Just replace the exiting Google Analytics code, wherever it is on the page, with the one in the box.

February 13, 2009 3:17 PM

Brian Kaldenberg said:

I have installed everything and it appears to be tracking exact keywords correctly.

Problem is when inside analytics if I click the "clicks" tab, none of the clicks, impressions, ctr, cost, etc. data is showing up for dimension user-defined.

I have auto-link tag set to on.

Clicks data shows up for my broad match adgroup, but isn't the point of exact keyword tracking to be able to see clicks data for exact keywords within broad match?

I sure hope it is possible.

February 27, 2009 1:58 AM

Nikki said:

Hi

Is there a way of relating the keyword input to the keyword bid on? e.g. a hybrid of yours and Brian Cliftons PPC terms methods (his override bid term filter). So that a client can see e.g. car parking (car+parking+greater+manchester) using the ga2.js file?

Thanks
Nikki

March 16, 2009 8:54 AM

Richie Rich said:

Hi Michael. I have been successfully using the code here on 6 PPC accounts and the information has proved invaluable - thx so much for this.
However today on 2 of my 6 accounts I have no adwords data showing in my analytics? (and therefor no excat keyword tracking. Have you experienced this before - it may very well be an adwords glitch? Any ideas?

March 25, 2009 8:26 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Richie: No idea why it's not working. Have you checked to make sure that your AdWords linking and cost data is all set up properly?

March 25, 2009 3:20 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Nikki: It seems like it would be possible using filters. Give it a go and let us know how it works out.

March 25, 2009 3:24 PM

Medela Dude said:

Hi Mike, appreciate your work on this and have been using it for a year or 2 now.

Any news on a resolution to the "Not Set" issue?

May 6, 2009 10:51 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Medela Dude: Not yet. There's just a lot of traffic from Google that doesn't match the standard query. We'll definitely keep everyone posted with any updates to the code. Be sure to add the ROI blog to your reader of choice or subscribe via email with the link at the top right.

May 6, 2009 2:27 PM

Salman said:

I have implemented the script. Works fine. It returns the actual KWs in the user defined reports, however there is no goal conversions associated with these KWs although i know that i have made conversions through these KWs.

May 15, 2009 12:17 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Salman: Try drilling down to the keyword level in the Keywords report where you should see your conversions. Then segment by User Defined. What do you see?

May 15, 2009 9:57 AM

Neal said:

Michael, does this keyword filter affect GA ecommerce data? I recently installed it in one of my sites...I see the specific queries from Adwords but don't see conversion data. Our overall ecommerce stats also show $0 revenue right after installing the GA code.

June 19, 2009 7:39 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Neal: It shouldn't affect ecommerce data. What happens when you remove it?

June 22, 2009 11:53 AM

Neal said:

Michael,

We installed the code and all ecommerce data stopped reporting. We were averaging several $30,000 in revenue per day and then it went to $0 after we changed the GA code. Any ideas?

June 24, 2009 9:57 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Neal: Have you tried using the Exact Keyword Tracking script on all pages but your receipt page?

June 25, 2009 4:58 PM

Vince said:

Can someone explain how we can embed this data into our Website forms so the search keywords and PPC data is added to our leads please?

Basically, trying to achieve the same as what Salesforce.com Google adwords integration has with their web-to-lead form.
http://www.semgeek.com/semgeek/2008/03/what-you-need-t.html

July 18, 2009 9:49 AM

neal@akamaiseo.com said:


Michael, are you saying that the modified GA script needs to be on every page of your site except for your confirmation/receipt page?

July 20, 2009 3:51 PM

afzal hanif said:

Really great post, thanx. Right now i'm using the alternate 'filter method' to show the true keywords, however, conversions are still only attributed to the original (adwords) keyword. Perhaps I overlooked, but will this javascript method also show conversions to the true keywords? Hope you can help me, thanx:)

August 6, 2009 3:55 AM

afzal hanif said:

Nice post. I have been using the alternate mode now for a while, but one issue with this: conversions are not attributed to the 'true keywords', but to the keyword defined in adwords. Will this method show actual conversions to the true keywords? Perhaps I missed it but thanx in advance:)!

August 11, 2009 10:44 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Afzal: Yes, it will. One benefit it has over the other method. Just be sure to use the user defined report.

August 19, 2009 10:22 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Neal: Technically it should be on every possible landing page. You can write conditional JavaScript to check and see whether or not this is this case, or you can just put it on every page. Either way works, really.

August 19, 2009 10:32 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Vince: That's a bit more complicated. Justin Cutroni has detailed a method for something similar at his blog. Hope it helps!

August 19, 2009 10:36 AM

Jen said:

thanks Michael and ROIRev. This one gave us substantial savings over a twelve month period.

September 4, 2009 4:51 AM

Guy said:

Great stuff!!
Any way to fix it to show utf-8 keywords?

October 9, 2009 11:26 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Guy: To be honest, I haven't spent a lot of time working on the script. If you'd like to add decoding for utf-8, please feel free! Just let us know of any updates so we can share the wealth.

October 9, 2009 1:24 PM

Riedel Wine Glass said:

So should this script be on every page in the website? sorry newbie question

December 22, 2009 3:18 PM

Wytze said:

Thanks a million Michael,

Your script has made our year! Like somebody else mentioned earlier. This information is invaluable! Only running for a couple of days and I've already seen so many incorrect queries!

I do have a question though, is there a way to associate costs to the queries like you see with Search Query reports in Adwords?

Thanks again so much and have an early merry christmas! :)

December 23, 2009 7:00 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Riedel: Yes, put it on every page of your site. It should replace the standard Google Analytics Tracking Code.

January 4, 2010 5:55 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Wytze: No, there's not currently a way to associate costs with the queries. We typically just use the SQR in AdWords to do that.

January 4, 2010 5:57 PM

David Ogletree said:

I used to work at a ppc agency and our Google rep gave me a filter that let me track search partners. I did not save the filter and I don't have access to that account anymore. I can't seem to find how to do this again. Can you make a filter that does this?

January 12, 2010 9:46 AM

GregBB said:

What would be the reasons to favor the ga.js update to view actual search phrases in comparison to applying the "Override Bid Term" filters? Is the result the same? One obvious reason is that you can instantly apply it to all profiles, which could also be a disincentive if you would like to have more flexibility. Would appreciate your thoughts. Thanks!

February 4, 2010 8:01 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@David: You can add a query parameter to your destination URLs and then use the special AdWords macro {placement} to insert the URL that the ad was displayed on, like so:

www.mysite.com?site={placement}

Then you can use something like Filters, Site Search or Custom Variables to pull that data out and put it into a Google Analytics report.

March 6, 2010 4:18 PM

Kevin Joyner said:

Hi Michael

I seem to have gathered the impression from somewhere that there are plans ultimately to deprecate the GA user defined variable, and that we should use custom variables where possible.

Would it be worthwhile to adapt your Keyword Sleuth script to use custom variables? If so, I don't suppose you've done that, have you? :-)

Many thanks

Kevin

April 20, 2010 9:00 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Kevin: We have, and it works just fine. Look for an article about it in the near future.

April 20, 2010 11:10 AM

Sandra said:

Ok...pardon the moron. I have read this entire thread and just want to make sure I understand completely b4 I implement the code.

1. I literally just REPLACE the code on my sites with the one up top u provide (obviously changing the profile numbers)?

2. Do I have to also upload this ga_keyword2.js file? If so, why?

Thanks so much - really looking 4ward to taking it for a test drive!

S

May 19, 2010 3:55 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Sandra: Yes, replace the code on your site with the one above. And, yes, you do need to upload the file. Why? Because that's where all the code that grabs the search query is.

May 25, 2010 9:42 AM

Eric said:

Hi Michael,

I wanted to thank you for this wonderful tool. We've been using it for almost 2 years and its benefit has been significant.

Yesterday, I upgraded my site to the new asynchronous GATC code but wasn't quite sure how to integrate ga_keyword.js so I took my best shot as shown below. No luck--the user defined value data has disappeared.

Actually, there are two problems here. Whenever I originally set up the 'traditional' GATC code with the two additional lines for cross-domain tracking, the UDV info would disappeared. We decided knowing what the original queries were outweighed cross domain tracking so we just left out the

pageTracker._setDomainName('none');
pageTracker._setAllowLinker(true);

lines and lived with the compromise. This time I included the asynchronous equivalent for cross domain hoping it would work but no luck.

_gaq.push(['_setDomainName', 'none']);
_gaq.push(['_setAllowLinker', true]);

So I've changed too many variables to know what the real problem is, but if this is a no-brainer for you, would you please point out my error. Alternately, I can go back and remove the cross domain asynchronous lines to try and isolate the cause and effect and see what happens.

Also noticed an early post about deprecating the _setVar() function and an upcoming post about that? Perhaps that post might be nearby?

Would be grateful for any help.

Eric.

Current Attempt:

<!--
<head>

<script src="ga_keyword.js" type="text/javascript"></script>

<script type="text/javascript">

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-123456-1']);

_gaq.push(['_setDomainName', 'none']);
_gaq.push(['_setAllowLinker', true]);

_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

</script>

</head>
-->

July 7, 2010 9:00 AM

Darrell said:

Google Adwords lets me generate a report of keyphrases typed that caused ads to show up and wheter they generated clicks or not. These are phrases typed during the search, including searches on other sites, not just the keyword that match the ad. I can then see phrases generating clicks that I don't like the words that are in them, then ad those to my negative keywords. Is this something new that was not available in 2008 when this ga_keyword script was created?

September 8, 2010 5:52 PM

George Strait Tickets said:

Then you can use something like Filters, Site Search or Custom Variables to pull that data out and put it into a Google Analytics report.

September 23, 2010 5:58 AM

Christina said:

I used to work at a ppc agency and our Google rep gave me a filter that let me track search partners. I did not save the filter and I don't have access to that account anymore. I can't seem to find how to do this again. Can you make a filter that does this

October 26, 2010 8:58 AM

PPC Whiz said:

This stuff is great! Keep up the good work team, I really appreciate you sharing this with the community. You are an excellent resource for us PPC guys out there looking to maximize our spend.
My clients will thank you!

February 14, 2008 3:25 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@PPC Whiz: Glad we could help out! Definitely keep posted here on any additions or updates, and like I said in my post, our own team will be posting some of their tips and tricks in the coming weeks.

February 14, 2008 4:22 PM

Jesse DaCosta said:

Hey Michael,

Thanks for the update, have been on the lookout for it! I've tried another method from another blog but that doesn't seem to work, at least for me, so now I've updated to the new code I'm going to test this out.

Thanks again!

February 14, 2008 4:37 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Jesse: Great! Let me know how it works for you. We're always trying to improve it.

February 14, 2008 5:54 PM

Christian Martin said:

Thanks for updating the ga.js script with this! I only saw the original change for the old urchin code yesterday after your webinar. I've already changed the GA code on both our site and looking forward to seeing the results in the coming days.

I do have a question... In the Traffic Sources::Keywords section, their are toggles for Show: total | paid | non-paid and then the Segment listbox.

On first glance, it would seem GA is providing everything without the script. Am I being simplistic in my cursory look?

Thanks again!

February 14, 2008 7:06 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Christian: Unfortunately, the Keywords report will only show you the bid terms for your paid search. Basically, it will show you the keyword phrase that you bid upon, but not the one that visitors actually typed into the search engine. Hope that makes sense.

February 15, 2008 9:32 AM

Dave Cardwell said:

Thanks for updating this script and sharing it with the community.

I'm curious - why the "UA-1" in this line of the script:
_gat._getTracker("UA-1");

February 15, 2008 11:51 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Dave: It's just a precaution, due to the way that setVar operates, and we've found that it leads to more accurate usage stats.

February 15, 2008 1:57 PM

Searchquant said:

Doesn't it seem strange that Google wouldn't make this a feature in G Analytics early on? It's clear any smart marketer's gonna want to know which queries within phrase or broad matched keywords are working and not working.

Google gets 70% of its revenue from phrase and broad match.

February 15, 2008 4:53 PM

Sonja Bakker said:

Hi,

This quiet cool. I already saw that the previous script wasn't working anymore. Going to try this one now!

February 18, 2008 11:27 AM

Julien Raby said:

Hi Michael,

thanks a lot for this new version of the script, I was using the old filter hacks but it doesn't work anymore...

One question: the script as it is now doesn't seem to work if I manually tag my link (I almost always tag my links instead of using the auto-tagging to gain more control over the utm_campaign variable...) so I was wondering if there were a quick fix fo manual link tagger like myself?

Thanks again,
Julien

February 19, 2008 6:54 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Julien: While we definitely don't recommend that you manually tag AdWords ads (it causes problems when Analytics links up the data between your two accounts), this method should work for manually tagged links, so long as those links are tagged with utm_medium=cpc and the visits are coming from a search engine with a plainly visible search query in the URL (e.g., q=search+query, p=search+query, query=search+query).

February 22, 2008 3:28 PM

Chris Bradley said:

Thanks for this, I just tried the other method last week and didn't get it to work so this comes at a great time for me but I do have one question..

Should I upload the script to my root directory?

February 24, 2008 2:41 PM

Shawn Purtell, Senior Web Analytics Engineer Author Profile Page said:

@Chris:

You can upload the file wherever you like. Most websites have a specific place where scripts are stored, but it's different for everybody. The important thing is to make sure the call to the .js script is pointing to the right place.

February 25, 2008 9:29 AM

Charles Meaden said:

The actual ga_keyword2.js script contains the following lines


var pageTracker = _gat._getTracker("UA-XXXXXX-X");

The page says not to edit the script, but should I be changing the [yoursitehere] and UA-XXXX lines so that they correspond to our tracking codes?

March 17, 2008 10:40 AM

Jeremy Aube, Director of Engineering Author Profile Page said:

@Charles: Those lines are just a re-iteration of the installation instructions as given in the article. They are just comments, so you don't need to change it.

March 18, 2008 10:48 AM

Charles Meaden said:

Jeremy,

Thank you. Two more questions if I may.

1. Does it make any difference if I have amended the code to use our details
2. Can I use remove the commented section from the ga_keyword2.js file then

March 19, 2008 6:55 AM

Jeremy Aube, Director of Engineering Author Profile Page said:

@Charles: You really shouldn't be making any changes to the javascript file. If you're just making changes to or removing the comment section, that won't affect the functionality of the script, but it would be best to leave it as is. Then anyone who looks at the script will have the version number, author, general instructions (rather than specific to a single site's setup), and when it was last modified. Any changes to the script itself could negatively affect its functionality. Michael has written this script very precisely so that it needs no modification to work with your site.

March 19, 2008 9:52 AM

Ron said:

ok, I really want to get this data from my analytics and I have upgraded to ga and installed the tracking code...but I can't for the life of me understand where I find the detailed keyword search data in my analytics account. Can someone point me in the right direction?

April 2, 2008 4:21 PM

Jeremy Aube, Director of Engineering Author Profile Page said:

@Ron: The Exact Keyword Data for the site will be in the User Defined Report. You can also segment various reports by the User Defined Variable to see this information for specific visitor traffic segments. See Michael's previous post for more information.

April 2, 2008 4:39 PM

Ron said:

So if I look in the tab "Visitor/UserDefined" and all I see under the user defined values is "not set" then it's safe to assume I screwed up in inserting the tracking code?

April 2, 2008 5:35 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Ron: Well, it either means that you screwed up, or that you don't have any paid search traffic coming into your site. The traffic has to be auto-tagged AdWords clicks or manually tagged clicks with utm_medium=cpc.

Good luck!

April 3, 2008 10:59 AM

Ryan said:

Okay, I feel like an idiot.

The code checks out fine. Analytics is otherwise tracking fine. And I am getting my adwords PPC traffic to come up.

But STILL, I'm only getting "not set".

Is there something I'm missing? Maybe something obscenely obvious?

Thanks so much!

June 3, 2008 10:06 AM

Ryan said:

Yup. I'm definitely an idiot.

1. Didn't change the .js src path.

2. Didn't upload the .js file.

June 3, 2008 10:34 AM

Eric said:

Thanks for making these scripts. I put them on my site about a week ago, and the info has been very valuable.

Unfortunately, about 50% of the data comes back as (not set) and a slightly better return of only 33% on Yahoo. I don't have my account autotagged for various reasons, but every keyword has it's own URL with utm_medium=cpc. Is this the normal capture for the script or perhaps I have done something wrong or does the order of the utm_ variables in the search string matter. Currently I set the source, medium, campaign and then the term.

Thanks again for this wonderful tool.

June 10, 2008 2:36 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Eric: Well, content network will never display a search query, and some of the search partner sites don't format the search query in the same way that Google does. 50% is about the norm for what I see.

If you can find the search network sites that your ads are running and provide them, I may be able to expand the script to use their search queries.

June 10, 2008 4:27 PM

Daniel Waisberg said:

Hi Michael,

Thank you very much for the feature it is wonderful.

I was wondering if this code can work together with the one created by John Henson from LunaMetrics: Stuff More Than One Value into GA\x92s User Defined Segment . If so, this would solve the issue of using other User Defined Variables together with it.

Thank you again.

June 22, 2008 4:05 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Daniel: I don't see why the two scripts wouldn't play nice together. :) It may require some modifications to the JavaScript. Give it a shot and let us know how it works out.

June 24, 2008 8:24 AM

Eran Malloch said:

Hi Michael,

I REALLY REALLY REALLY need this tool to work (great idea and thanks to all who developed it), but unfortunately, whenever I add it to a site created by our webdesign partners, it somehow interferes with the script that creates their drop-down menu system, and the menu system stops working... :(

This has happened on 2 seperate sites now, and obviously we have to remove your script because a non-working menu system just aint gonna cut it. ;)

I'm guessing if this is happening to me, there are probably others it is happening to as well, but perhaps they haven't bothered to contact you and mention it.

ANY help you (or anyone else reading this comment) can provide with this issue would be GREATLY appreciated. I am happy to email you the offending site urls, etc.

Thanks in advance for your time, and I really do appreciate your efforts to provide this vital tool (and bah humbug to Google for NOT providing it) ;)


Eran Malloch
WCR Internet Marketing
Perth, Western Australia

July 11, 2008 2:22 AM

wil said:

How do I create a report that shows side-by-side the keyword in the AdWords campaign that was triggered along with the user defined variable (the search term). Right now, under traffic sources, I can see one or the other.

Thanks,

Wil

July 12, 2008 2:27 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Eran: I'd check to make sure that none of the functions from the menu system interfere with the keyword script. Beyond that, I don't see why it would cause any problems. Because of the sheer number of setups and JavaScript present on websites, there's no possible way we can troubleshoot each individual issue with the script, but if you have any additional comments on precisely what is going on (error messages, etc.), then maybe we can help out.

July 21, 2008 1:29 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Wil: There is no such report, but you could create a new profile with an Advanced Filter that plugs the User Defined field into the Campaign Term field. Just cram 'em both together, and that way when you look at your keywords list, you would see:

"bid term (search term)"

This will mean that cost and click data for your AdWords Campaigns keyword report will not match up properly, thus the reason why I recommend creating an additional profile.

Hope that helps.

July 21, 2008 1:36 PM

Eric Werner said:

Hi and thanks! One quick question, what does this do?

pageTracker._initData();

This line isn't in the code that Google gave me and you didn't mention anything about it in the post so I wanted to check.

Thanks!

August 8, 2008 12:18 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Eric: pageTracker._initData() is a deprecated function that was previously required before running the Google Analytics pageTracker. You can get rid of it or keep it in; entirely up to you.

August 8, 2008 1:52 PM

Jason said:

Michael - I've modified a function in the ga_keyword2.js code that I find quite useful re: more accurate stats gathering:

function noPercent(x)
{
x = unescape(x);
x = x.replace(/\+/g," ").replace(/^\s\s*/, '').replace(/\s\s*$/, '');
return x.toLowerCase(); // added feature
}


this basically groups all upper & lower case variations so that I get an accurate picture of the number of people using a particular word or phrase. Great script!

August 14, 2008 9:44 PM

Ricky said:

I think that this script looks great, and I have just updated the script on our site to check it out.

Though one question still remains, how does this differ from the report you get out of Adwords that shows you which search results that triggered your adwords to show and generate a click?

Thanks!

August 19, 2008 8:14 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Ricky: Check out my co-worker Mark Curtis' article on the Keyword Sleuth script versus the AdWords Search Query Performance Report for the answer to your question.

August 19, 2008 10:17 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Jason: Thanks for the info. You could also use a lowercase filter inside of Google Analytics if you don't want to modify the code (if, for instance, it's already installed on your site).

August 19, 2008 10:19 AM

Eric S said:

Michael, thanks again for this wonderful script. I recently upgraded to the new tracking code and the script worked fine. Unfortunately, my 'check-out' is handled by a third party that is still running the legacy script and they are hesitant to upgrade. Note that their legacy script also has

_udn="none";
_ulink=1;

in the legacy code to enable cross-domain tracking.

So, I downgraded back to the legacy code and added the two lines for cross-domain tracking code that I had not used before, and the next day all of my User Defined Value data was missing. So I deleted the

_udn="none";
_ulink=1;

lines and it immediately returned but this left me without the cross domain tracking I had hoped to gain. Note that the User Defined Value came through just fine in the ga.js version except the link was broken across the domains due to code incompatability. Any suggestions for getting the legacy version to work cross-domain. I noticed that the slueth(); function was in the legacy code on your first blog in 07 but not the more recent blog. Might this be part of it?

On a completely separate issue, I appended the cpc search term that actually responded to the original user query to the UDV and was stunned at the level of mismatch. For example, I had a phrase/exact match bid for "word1 word2 word3 word4", the user queried the exact term "word1 word2 word3 word4" but Google responded to the query with a broad matched term "word1 word2 wordX" where wordX was barely a synonym but the price point was much higher--not to mention the ad displayed to the user's query was far less relevant because the reponse came from a different ad group. Google does this a lot.

Do you see this mis-matching to increase Search Engine revenues a lot and does your consulting service offer methods of combating this problem of what seems a lot like fraud?

August 31, 2008 8:45 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Eric S: As long as you properly tag links between domains with utmLinker, you should be fine. It should bridge the gap between domains with the right cookie information.

Good luck!

September 2, 2008 3:24 PM

Mike said:

Hi Michael,

I am on the ROI GA Online training.

I have installed the Sleuth Tracking code, but I get "(not set)" when I go check the User Defined data.

I cannot spot what I am doing wrong.

You can view my code in the source of this page:

http://www.enquete-satisfaction.com/

Thanks for your help!
Mike

October 6, 2008 9:06 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Mike: The ga_keyword2.js file must go between the first <script> section of the Google Analytics Tracking Code and the second. You have it before. Please read the article again and be sure to place it in precisely the spot that I indicated. That should fix it for you.

You also should be wary of "smart" or curled quotes showing up in your code. If you use Microsoft Outlook or Word to edit code with quotation marks and paste it into your site, you might end up with a left or a right curled quote (“ or ”) instead of a standard quote ("). Be sure to only use standard quote marks in HTML code.

October 6, 2008 11:03 AM

Mike said:

Michael,

Could it be that I had copied the code from an older version of the article?

I am asking since my code also includes Sleuth() at the end, that the new code doesn't seem to include.

Thanks for your help!
Mike

October 8, 2008 9:52 AM

Eddy said:

This is a great script that I have been using flawlessly for a while now, but for the past month or so, all the keywords within the user defined page are still attached to the Google search query that is after the q variable as in http://www.google.co.uk/search?hl=en&q=keyword1+keyword2&meta=
I dont understand why this has started happening but could do with some advice.

thanks
eddy

October 8, 2008 11:43 AM

Eddy said:

Michael, if not done so already is it possible to add the search queries for the following Google search network partners?
aolsearch.aol.co.uk
www.winbuyer.co.uk
search.babylon.com
www.kellysearch.co.uk
business.shop.ebay.co.uk
search.virginmedia.com
www.hotfroguk.co.uk
uk.ask.com
www.tiscali.co.uk
search1.sky.com
search.mywebsearch.com

there are quite a few more but they generate just one or two visits.

regards
eddy

October 8, 2008 12:35 PM

art said:

Great script. Cant wait to see the results.

October 12, 2008 10:35 PM

Mike said:

Hi Michael,

I got the script to work. However, there are 2 issues:

1) About 20-25% of the visits show as "not set" (I don't use content for that campaign, only search with Google & Search Network).

Can you tell what they could account for?

2) It's a campaign with French keywords and the script doesn't capture the accents properly (whereas GA's Traffic Sources > Keyword Report does). E.g. the word "pr\xE9vention" shows as "prévention".

Is there a way to correct that?

Thanks!
Mike

October 13, 2008 8:04 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Mike: The reason why 20-25% of your visits are "not set" is because the script currently does not account for all of the engines that are a part of the Google search network. We've been working on an update for that, which should be released in the next few days, and should reduce the percentage of "not sets".

We'll also work on getting the accents fixed. Thanks for letting me know!

October 14, 2008 10:42 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Eddy: I'm not really sure what you mean by this. Can you illustrate with a screenshot or a URL?

October 14, 2008 10:45 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Eddy: I've been working on the script, trying to increase the number of search engine query parameters that it recognizes. Thanks for your list, and look for an update over the next few days.

October 14, 2008 10:46 AM

art said:

Great tool! I have started to see the results and they are amazing. 80% of my visits are showing as "not set". Are they all as a results of google parters not being included or because I haven't set utm_medium=ppc for both yahoo and msn ppc traffic? the interesting part is the bulk of our revenue is coming from google partners/or the other engines...the "not set" portion.

Second question..I want to add another domain which is an add-on to the main domain..Do I follow the exact steps for additional domains.

October 15, 2008 12:42 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Art: It could be because you haven't set utm_medium=cpc for Yahoo! and MSN paid traffic. Many Google partners aren't included yet, either, but I'll be posting an update to the script that will contain more of those partners. Keep an eye out on the blog, or subscribe to it to keep up-to-date.

October 15, 2008 10:26 AM

Clikckbank Affiliates said:

Thanks for the update...

October 20, 2008 3:14 PM

Moses Chang said:

Hi, just stumbled upon this tool and immediately created a new Google Analytics account for our website and installed it. Do I lose the ability to track AdWords Campaigns (under the Traffic Sources tab in Google Analytics) once this tool is installed? I also can't find where the search query info are being displayed...

Thanks in advance,
Moses

October 22, 2008 10:46 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Moses: This won't affect your AdWords Campaigns report and won't take away your ability to track campaigns, adgroups, or keywords. To access the exact keyword information, you can either drill down to a specific campaign/adgroup/keyword in the Traffic Sources > AdWords > AdWords Campaigns report and use the Dimension User Defined dropdown.

You can also view all of your exact keyword combinations using the Visitors > User Defined report.

October 22, 2008 11:01 AM

Aidin said:

How does this differ from the filter hack? Which one is better?

November 4, 2008 6:04 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Aidin: Check out my first article when I first created the script for how it differs from Omega's filter hack. I like the script better for the reasons outlined there.

November 5, 2008 1:32 PM

Gavin Doolan said:

Hi there,
I wonder if its possible to concatenate search queries to the user defined value to see data before the last click. (preventing a last click wins scenario)

What I mean is see the string of keywords used before a purchase. Say during the buyer research phase, till the point of purchase?

Obviously there is also the issue of previous campaigns which triggered a visit such as banner / email but I figured this may be the place to mention such an idea.

I've only just started to learn JS myself, perhaps by the time I'm finished reading my current book I'll have an idea on how to do it myself.

Cheers,
Gavin.

November 12, 2008 5:00 AM

Mike said:

Hello Michael,

Are you aware of this Advanced Filter setup that shows the bid keyword + exact search query?

http://www.ga-experts.com/blog/2006/11/how-to-get-detailed-ppc-keyword-data-from-google-analytics/

If so can you comment on the advantages/disadvantages of yours vs. theirs?

One thing that comes to mind is that theirs leaves the User Defined variable free for another utilization.

Thanks!
Mike

November 18, 2008 4:05 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Gavin: It's definitely possible. We've been working on something very similar here. Good luck on your own JS pursuits! Let us know if you post something about this elsewhere and we'll be sure to give you some link love.

November 19, 2008 3:11 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Mike: Definitely. It was Brian's filter that inspired me. The only issue I had with their is how it works on return visits to sites. See my original article for a full explanation.

November 19, 2008 3:13 PM

Aidin said:

Is there a way to implement this script to another profile?The first profile is already using the user defined field by live person chat. Could the two coexist within the same profile?

November 26, 2008 4:03 PM

Bud Gibson said:

How does this play with something like advanced segmentation? I was looking at those reports, and they seem to show what percentage of your search traffic for a given keyword is from paid sources.

The one thing I can see is that I might be able to see how my keywords are broad matching to actual search terms.

December 9, 2008 8:36 AM

Amit said:

Hi Michael,

Awesome post!
I was wondering if combining all the javascript in to a single .js file would be ok?

ON THE WEBPAGE YOUR WOULD PUT:

THE CONTENTS ON MyGA.js WOULD LOOK AS FOLLOWS:

var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));

function noPercent(x)
{
x = unescape(x);
return x.replace(/\+/g," ").replace(/^\s\s*/, '').replace(/\s\s*$/, '');
}

function getRef()
{
ref = document.referrer;
re = /(\?|&)(q|p|query|encquery|qt|terms|rdata|qs|wd|text|szukaj|k|searchExpr|
search_for|string|search_query|searchfor)=([^&]+)/;
searchq = re.exec(ref);
if(searchq) {
searchq[3] = noPercent(searchq[3]);
sleuthTracker._setVar(searchq[3]);
}
else {
sleuthTracker._setVar('Referral: ' + document.referrer);
}
}

function sleuth()
{
if(document.location.search.indexOf("gclid")!=-1||
document.location.search.indexOf("cpc")!=-1) {
getRef();
}
}

var sleuthTracker = _gat._getTracker("UA-1");
sleuthTracker._initData();
sleuth();

var pageTracker = _gat._getTracker("UA-XXXXXX-1");
pageTracker._initData();
pageTracker._trackPageview();

December 24, 2008 4:45 AM

Amit said:

no worries, I figured out why they need to be seperate. Thanks!

December 24, 2008 5:16 AM

rookie said:

The script works great!!
Can somebody help me to modify the script to append the ip of the user next to the search string? This would be invaluable for our statistical analysis. Unfortunately my javascript knowledge is limited. Thanks in advance!

January 4, 2009 6:22 PM

Bud Gibson said:

I just installed this script. An observation: why didn't you name space it? That would eliminate almost all possibilities of javascript conflict which I noticed one commenter remarking. I may do that myself if I get some spare time. It just involves encapsulating your functions in an object with a particular name. You then access the functions with Object.functionName().

January 7, 2009 10:37 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Amit: Yep, there's a reason why they're separate, though you can wrangle the JavaScript in such a way that there's only a single reference for all Google Analytics code, if you wanted to.

January 29, 2009 1:37 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@rookie: Glad the script is working for you!

As pulling IP addresses into Google Analytics actually violates the terms and conditions (and is impossible to do with JavaScript alone), there are currently no plans to add this functionality to the script.

January 29, 2009 1:43 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Bud: We have been testing a version of this script internally that expands on the features and uses object-oriented coding, but you're welcome to post your own.

January 29, 2009 1:50 PM

satin jain said:

but where i put this code..

i m new about this stuff...

please tell me where i have two put this script ...

please tell me...

February 13, 2009 2:55 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@satin jain: Just replace the exiting Google Analytics code, wherever it is on the page, with the one in the box.

February 13, 2009 3:17 PM

Brian Kaldenberg said:

I have installed everything and it appears to be tracking exact keywords correctly.

Problem is when inside analytics if I click the "clicks" tab, none of the clicks, impressions, ctr, cost, etc. data is showing up for dimension user-defined.

I have auto-link tag set to on.

Clicks data shows up for my broad match adgroup, but isn't the point of exact keyword tracking to be able to see clicks data for exact keywords within broad match?

I sure hope it is possible.

February 27, 2009 1:58 AM

Nikki said:

Hi

Is there a way of relating the keyword input to the keyword bid on? e.g. a hybrid of yours and Brian Cliftons PPC terms methods (his override bid term filter). So that a client can see e.g. car parking (car+parking+greater+manchester) using the ga2.js file?

Thanks
Nikki

March 16, 2009 8:54 AM

Richie Rich said:

Hi Michael. I have been successfully using the code here on 6 PPC accounts and the information has proved invaluable - thx so much for this.
However today on 2 of my 6 accounts I have no adwords data showing in my analytics? (and therefor no excat keyword tracking. Have you experienced this before - it may very well be an adwords glitch? Any ideas?

March 25, 2009 8:26 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Richie: No idea why it's not working. Have you checked to make sure that your AdWords linking and cost data is all set up properly?

March 25, 2009 3:20 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Nikki: It seems like it would be possible using filters. Give it a go and let us know how it works out.

March 25, 2009 3:24 PM

Medela Dude said:

Hi Mike, appreciate your work on this and have been using it for a year or 2 now.

Any news on a resolution to the "Not Set" issue?

May 6, 2009 10:51 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Medela Dude: Not yet. There's just a lot of traffic from Google that doesn't match the standard query. We'll definitely keep everyone posted with any updates to the code. Be sure to add the ROI blog to your reader of choice or subscribe via email with the link at the top right.

May 6, 2009 2:27 PM

Salman said:

I have implemented the script. Works fine. It returns the actual KWs in the user defined reports, however there is no goal conversions associated with these KWs although i know that i have made conversions through these KWs.

May 15, 2009 12:17 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Salman: Try drilling down to the keyword level in the Keywords report where you should see your conversions. Then segment by User Defined. What do you see?

May 15, 2009 9:57 AM

Neal said:

Michael, does this keyword filter affect GA ecommerce data? I recently installed it in one of my sites...I see the specific queries from Adwords but don't see conversion data. Our overall ecommerce stats also show $0 revenue right after installing the GA code.

June 19, 2009 7:39 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Neal: It shouldn't affect ecommerce data. What happens when you remove it?

June 22, 2009 11:53 AM

Neal said:

Michael,

We installed the code and all ecommerce data stopped reporting. We were averaging several $30,000 in revenue per day and then it went to $0 after we changed the GA code. Any ideas?

June 24, 2009 9:57 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Neal: Have you tried using the Exact Keyword Tracking script on all pages but your receipt page?

June 25, 2009 4:58 PM

Vince said:

Can someone explain how we can embed this data into our Website forms so the search keywords and PPC data is added to our leads please?

Basically, trying to achieve the same as what Salesforce.com Google adwords integration has with their web-to-lead form.
http://www.semgeek.com/semgeek/2008/03/what-you-need-t.html

July 18, 2009 9:49 AM

neal@akamaiseo.com said:


Michael, are you saying that the modified GA script needs to be on every page of your site except for your confirmation/receipt page?

July 20, 2009 3:51 PM

afzal hanif said:

Really great post, thanx. Right now i'm using the alternate 'filter method' to show the true keywords, however, conversions are still only attributed to the original (adwords) keyword. Perhaps I overlooked, but will this javascript method also show conversions to the true keywords? Hope you can help me, thanx:)

August 6, 2009 3:55 AM

afzal hanif said:

Nice post. I have been using the alternate mode now for a while, but one issue with this: conversions are not attributed to the 'true keywords', but to the keyword defined in adwords. Will this method show actual conversions to the true keywords? Perhaps I missed it but thanx in advance:)!

August 11, 2009 10:44 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Afzal: Yes, it will. One benefit it has over the other method. Just be sure to use the user defined report.

August 19, 2009 10:22 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Neal: Technically it should be on every possible landing page. You can write conditional JavaScript to check and see whether or not this is this case, or you can just put it on every page. Either way works, really.

August 19, 2009 10:32 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Vince: That's a bit more complicated. Justin Cutroni has detailed a method for something similar at his blog. Hope it helps!

August 19, 2009 10:36 AM

Jen said:

thanks Michael and ROIRev. This one gave us substantial savings over a twelve month period.

September 4, 2009 4:51 AM

Guy said:

Great stuff!!
Any way to fix it to show utf-8 keywords?

October 9, 2009 11:26 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Guy: To be honest, I haven't spent a lot of time working on the script. If you'd like to add decoding for utf-8, please feel free! Just let us know of any updates so we can share the wealth.

October 9, 2009 1:24 PM

Riedel Wine Glass said:

So should this script be on every page in the website? sorry newbie question

December 22, 2009 3:18 PM

Wytze said:

Thanks a million Michael,

Your script has made our year! Like somebody else mentioned earlier. This information is invaluable! Only running for a couple of days and I've already seen so many incorrect queries!

I do have a question though, is there a way to associate costs to the queries like you see with Search Query reports in Adwords?

Thanks again so much and have an early merry christmas! :)

December 23, 2009 7:00 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Riedel: Yes, put it on every page of your site. It should replace the standard Google Analytics Tracking Code.

January 4, 2010 5:55 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Wytze: No, there's not currently a way to associate costs with the queries. We typically just use the SQR in AdWords to do that.

January 4, 2010 5:57 PM

David Ogletree said:

I used to work at a ppc agency and our Google rep gave me a filter that let me track search partners. I did not save the filter and I don't have access to that account anymore. I can't seem to find how to do this again. Can you make a filter that does this?

January 12, 2010 9:46 AM

GregBB said:

What would be the reasons to favor the ga.js update to view actual search phrases in comparison to applying the "Override Bid Term" filters? Is the result the same? One obvious reason is that you can instantly apply it to all profiles, which could also be a disincentive if you would like to have more flexibility. Would appreciate your thoughts. Thanks!

February 4, 2010 8:01 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@David: You can add a query parameter to your destination URLs and then use the special AdWords macro {placement} to insert the URL that the ad was displayed on, like so:

www.mysite.com?site={placement}

Then you can use something like Filters, Site Search or Custom Variables to pull that data out and put it into a Google Analytics report.

March 6, 2010 4:18 PM

Kevin Joyner said:

Hi Michael

I seem to have gathered the impression from somewhere that there are plans ultimately to deprecate the GA user defined variable, and that we should use custom variables where possible.

Would it be worthwhile to adapt your Keyword Sleuth script to use custom variables? If so, I don't suppose you've done that, have you? :-)

Many thanks

Kevin

April 20, 2010 9:00 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Kevin: We have, and it works just fine. Look for an article about it in the near future.

April 20, 2010 11:10 AM

Sandra said:

Ok...pardon the moron. I have read this entire thread and just want to make sure I understand completely b4 I implement the code.

1. I literally just REPLACE the code on my sites with the one up top u provide (obviously changing the profile numbers)?

2. Do I have to also upload this ga_keyword2.js file? If so, why?

Thanks so much - really looking 4ward to taking it for a test drive!

S

May 19, 2010 3:55 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Sandra: Yes, replace the code on your site with the one above. And, yes, you do need to upload the file. Why? Because that's where all the code that grabs the search query is.

May 25, 2010 9:42 AM

Eric said:

Hi Michael,

I wanted to thank you for this wonderful tool. We've been using it for almost 2 years and its benefit has been significant.

Yesterday, I upgraded my site to the new asynchronous GATC code but wasn't quite sure how to integrate ga_keyword.js so I took my best shot as shown below. No luck--the user defined value data has disappeared.

Actually, there are two problems here. Whenever I originally set up the 'traditional' GATC code with the two additional lines for cross-domain tracking, the UDV info would disappeared. We decided knowing what the original queries were outweighed cross domain tracking so we just left out the

pageTracker._setDomainName('none');
pageTracker._setAllowLinker(true);

lines and lived with the compromise. This time I included the asynchronous equivalent for cross domain hoping it would work but no luck.

_gaq.push(['_setDomainName', 'none']);
_gaq.push(['_setAllowLinker', true]);

So I've changed too many variables to know what the real problem is, but if this is a no-brainer for you, would you please point out my error. Alternately, I can go back and remove the cross domain asynchronous lines to try and isolate the cause and effect and see what happens.

Also noticed an early post about deprecating the _setVar() function and an upcoming post about that? Perhaps that post might be nearby?

Would be grateful for any help.

Eric.

Current Attempt:

<!--
<head>

<script src="ga_keyword.js" type="text/javascript"></script>

<script type="text/javascript">

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-123456-1']);

_gaq.push(['_setDomainName', 'none']);
_gaq.push(['_setAllowLinker', true]);

_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

</script>

</head>
-->

July 7, 2010 9:00 AM

Darrell said:

Google Adwords lets me generate a report of keyphrases typed that caused ads to show up and wheter they generated clicks or not. These are phrases typed during the search, including searches on other sites, not just the keyword that match the ad. I can then see phrases generating clicks that I don't like the words that are in them, then ad those to my negative keywords. Is this something new that was not available in 2008 when this ga_keyword script was created?

September 8, 2010 5:52 PM

George Strait Tickets said:

Then you can use something like Filters, Site Search or Custom Variables to pull that data out and put it into a Google Analytics report.

September 23, 2010 5:58 AM

Christina said:

I used to work at a ppc agency and our Google rep gave me a filter that let me track search partners. I did not save the filter and I don't have access to that account anymore. I can't seem to find how to do this again. Can you make a filter that does this

October 26, 2010 8:58 AM

PPC Whiz said:

This stuff is great! Keep up the good work team, I really appreciate you sharing this with the community. You are an excellent resource for us PPC guys out there looking to maximize our spend.
My clients will thank you!

February 14, 2008 3:25 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@PPC Whiz: Glad we could help out! Definitely keep posted here on any additions or updates, and like I said in my post, our own team will be posting some of their tips and tricks in the coming weeks.

February 14, 2008 4:22 PM

Jesse DaCosta said:

Hey Michael,

Thanks for the update, have been on the lookout for it! I've tried another method from another blog but that doesn't seem to work, at least for me, so now I've updated to the new code I'm going to test this out.

Thanks again!

February 14, 2008 4:37 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Jesse: Great! Let me know how it works for you. We're always trying to improve it.

February 14, 2008 5:54 PM

Christian Martin said:

Thanks for updating the ga.js script with this! I only saw the original change for the old urchin code yesterday after your webinar. I've already changed the GA code on both our site and looking forward to seeing the results in the coming days.

I do have a question... In the Traffic Sources::Keywords section, their are toggles for Show: total | paid | non-paid and then the Segment listbox.

On first glance, it would seem GA is providing everything without the script. Am I being simplistic in my cursory look?

Thanks again!

February 14, 2008 7:06 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Christian: Unfortunately, the Keywords report will only show you the bid terms for your paid search. Basically, it will show you the keyword phrase that you bid upon, but not the one that visitors actually typed into the search engine. Hope that makes sense.

February 15, 2008 9:32 AM

Dave Cardwell said:

Thanks for updating this script and sharing it with the community.

I'm curious - why the "UA-1" in this line of the script:
_gat._getTracker("UA-1");

February 15, 2008 11:51 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Dave: It's just a precaution, due to the way that setVar operates, and we've found that it leads to more accurate usage stats.

February 15, 2008 1:57 PM

Searchquant said:

Doesn't it seem strange that Google wouldn't make this a feature in G Analytics early on? It's clear any smart marketer's gonna want to know which queries within phrase or broad matched keywords are working and not working.

Google gets 70% of its revenue from phrase and broad match.

February 15, 2008 4:53 PM

Sonja Bakker said:

Hi,

This quiet cool. I already saw that the previous script wasn't working anymore. Going to try this one now!

February 18, 2008 11:27 AM

Julien Raby said:

Hi Michael,

thanks a lot for this new version of the script, I was using the old filter hacks but it doesn't work anymore...

One question: the script as it is now doesn't seem to work if I manually tag my link (I almost always tag my links instead of using the auto-tagging to gain more control over the utm_campaign variable...) so I was wondering if there were a quick fix fo manual link tagger like myself?

Thanks again,
Julien

February 19, 2008 6:54 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Julien: While we definitely don't recommend that you manually tag AdWords ads (it causes problems when Analytics links up the data between your two accounts), this method should work for manually tagged links, so long as those links are tagged with utm_medium=cpc and the visits are coming from a search engine with a plainly visible search query in the URL (e.g., q=search+query, p=search+query, query=search+query).

February 22, 2008 3:28 PM

Chris Bradley said:

Thanks for this, I just tried the other method last week and didn't get it to work so this comes at a great time for me but I do have one question..

Should I upload the script to my root directory?

February 24, 2008 2:41 PM

Shawn Purtell, Senior Web Analytics Engineer Author Profile Page said:

@Chris:

You can upload the file wherever you like. Most websites have a specific place where scripts are stored, but it's different for everybody. The important thing is to make sure the call to the .js script is pointing to the right place.

February 25, 2008 9:29 AM

Charles Meaden said:

The actual ga_keyword2.js script contains the following lines


var pageTracker = _gat._getTracker("UA-XXXXXX-X");

The page says not to edit the script, but should I be changing the [yoursitehere] and UA-XXXX lines so that they correspond to our tracking codes?

March 17, 2008 10:40 AM

Jeremy Aube, Director of Engineering Author Profile Page said:

@Charles: Those lines are just a re-iteration of the installation instructions as given in the article. They are just comments, so you don't need to change it.

March 18, 2008 10:48 AM

Charles Meaden said:

Jeremy,

Thank you. Two more questions if I may.

1. Does it make any difference if I have amended the code to use our details
2. Can I use remove the commented section from the ga_keyword2.js file then

March 19, 2008 6:55 AM

Jeremy Aube, Director of Engineering Author Profile Page said:

@Charles: You really shouldn't be making any changes to the javascript file. If you're just making changes to or removing the comment section, that won't affect the functionality of the script, but it would be best to leave it as is. Then anyone who looks at the script will have the version number, author, general instructions (rather than specific to a single site's setup), and when it was last modified. Any changes to the script itself could negatively affect its functionality. Michael has written this script very precisely so that it needs no modification to work with your site.

March 19, 2008 9:52 AM

Ron said:

ok, I really want to get this data from my analytics and I have upgraded to ga and installed the tracking code...but I can't for the life of me understand where I find the detailed keyword search data in my analytics account. Can someone point me in the right direction?

April 2, 2008 4:21 PM

Jeremy Aube, Director of Engineering Author Profile Page said:

@Ron: The Exact Keyword Data for the site will be in the User Defined Report. You can also segment various reports by the User Defined Variable to see this information for specific visitor traffic segments. See Michael's previous post for more information.

April 2, 2008 4:39 PM

Ron said:

So if I look in the tab "Visitor/UserDefined" and all I see under the user defined values is "not set" then it's safe to assume I screwed up in inserting the tracking code?

April 2, 2008 5:35 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Ron: Well, it either means that you screwed up, or that you don't have any paid search traffic coming into your site. The traffic has to be auto-tagged AdWords clicks or manually tagged clicks with utm_medium=cpc.

Good luck!

April 3, 2008 10:59 AM

Ryan said:

Okay, I feel like an idiot.

The code checks out fine. Analytics is otherwise tracking fine. And I am getting my adwords PPC traffic to come up.

But STILL, I'm only getting "not set".

Is there something I'm missing? Maybe something obscenely obvious?

Thanks so much!

June 3, 2008 10:06 AM

Ryan said:

Yup. I'm definitely an idiot.

1. Didn't change the .js src path.

2. Didn't upload the .js file.

June 3, 2008 10:34 AM

Eric said:

Thanks for making these scripts. I put them on my site about a week ago, and the info has been very valuable.

Unfortunately, about 50% of the data comes back as (not set) and a slightly better return of only 33% on Yahoo. I don't have my account autotagged for various reasons, but every keyword has it's own URL with utm_medium=cpc. Is this the normal capture for the script or perhaps I have done something wrong or does the order of the utm_ variables in the search string matter. Currently I set the source, medium, campaign and then the term.

Thanks again for this wonderful tool.

June 10, 2008 2:36 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Eric: Well, content network will never display a search query, and some of the search partner sites don't format the search query in the same way that Google does. 50% is about the norm for what I see.

If you can find the search network sites that your ads are running and provide them, I may be able to expand the script to use their search queries.

June 10, 2008 4:27 PM

Daniel Waisberg said:

Hi Michael,

Thank you very much for the feature it is wonderful.

I was wondering if this code can work together with the one created by John Henson from LunaMetrics: Stuff More Than One Value into GA\x92s User Defined Segment . If so, this would solve the issue of using other User Defined Variables together with it.

Thank you again.

June 22, 2008 4:05 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Daniel: I don't see why the two scripts wouldn't play nice together. :) It may require some modifications to the JavaScript. Give it a shot and let us know how it works out.

June 24, 2008 8:24 AM

Eran Malloch said:

Hi Michael,

I REALLY REALLY REALLY need this tool to work (great idea and thanks to all who developed it), but unfortunately, whenever I add it to a site created by our webdesign partners, it somehow interferes with the script that creates their drop-down menu system, and the menu system stops working... :(

This has happened on 2 seperate sites now, and obviously we have to remove your script because a non-working menu system just aint gonna cut it. ;)

I'm guessing if this is happening to me, there are probably others it is happening to as well, but perhaps they haven't bothered to contact you and mention it.

ANY help you (or anyone else reading this comment) can provide with this issue would be GREATLY appreciated. I am happy to email you the offending site urls, etc.

Thanks in advance for your time, and I really do appreciate your efforts to provide this vital tool (and bah humbug to Google for NOT providing it) ;)


Eran Malloch
WCR Internet Marketing
Perth, Western Australia

July 11, 2008 2:22 AM

wil said:

How do I create a report that shows side-by-side the keyword in the AdWords campaign that was triggered along with the user defined variable (the search term). Right now, under traffic sources, I can see one or the other.

Thanks,

Wil

July 12, 2008 2:27 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Eran: I'd check to make sure that none of the functions from the menu system interfere with the keyword script. Beyond that, I don't see why it would cause any problems. Because of the sheer number of setups and JavaScript present on websites, there's no possible way we can troubleshoot each individual issue with the script, but if you have any additional comments on precisely what is going on (error messages, etc.), then maybe we can help out.

July 21, 2008 1:29 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Wil: There is no such report, but you could create a new profile with an Advanced Filter that plugs the User Defined field into the Campaign Term field. Just cram 'em both together, and that way when you look at your keywords list, you would see:

"bid term (search term)"

This will mean that cost and click data for your AdWords Campaigns keyword report will not match up properly, thus the reason why I recommend creating an additional profile.

Hope that helps.

July 21, 2008 1:36 PM

Eric Werner said:

Hi and thanks! One quick question, what does this do?

pageTracker._initData();

This line isn't in the code that Google gave me and you didn't mention anything about it in the post so I wanted to check.

Thanks!

August 8, 2008 12:18 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Eric: pageTracker._initData() is a deprecated function that was previously required before running the Google Analytics pageTracker. You can get rid of it or keep it in; entirely up to you.

August 8, 2008 1:52 PM

Jason said:

Michael - I've modified a function in the ga_keyword2.js code that I find quite useful re: more accurate stats gathering:

function noPercent(x)
{
x = unescape(x);
x = x.replace(/\+/g," ").replace(/^\s\s*/, '').replace(/\s\s*$/, '');
return x.toLowerCase(); // added feature
}


this basically groups all upper & lower case variations so that I get an accurate picture of the number of people using a particular word or phrase. Great script!

August 14, 2008 9:44 PM

Ricky said:

I think that this script looks great, and I have just updated the script on our site to check it out.

Though one question still remains, how does this differ from the report you get out of Adwords that shows you which search results that triggered your adwords to show and generate a click?

Thanks!

August 19, 2008 8:14 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Ricky: Check out my co-worker Mark Curtis' article on the Keyword Sleuth script versus the AdWords Search Query Performance Report for the answer to your question.

August 19, 2008 10:17 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Jason: Thanks for the info. You could also use a lowercase filter inside of Google Analytics if you don't want to modify the code (if, for instance, it's already installed on your site).

August 19, 2008 10:19 AM

Eric S said:

Michael, thanks again for this wonderful script. I recently upgraded to the new tracking code and the script worked fine. Unfortunately, my 'check-out' is handled by a third party that is still running the legacy script and they are hesitant to upgrade. Note that their legacy script also has

_udn="none";
_ulink=1;

in the legacy code to enable cross-domain tracking.

So, I downgraded back to the legacy code and added the two lines for cross-domain tracking code that I had not used before, and the next day all of my User Defined Value data was missing. So I deleted the

_udn="none";
_ulink=1;

lines and it immediately returned but this left me without the cross domain tracking I had hoped to gain. Note that the User Defined Value came through just fine in the ga.js version except the link was broken across the domains due to code incompatability. Any suggestions for getting the legacy version to work cross-domain. I noticed that the slueth(); function was in the legacy code on your first blog in 07 but not the more recent blog. Might this be part of it?

On a completely separate issue, I appended the cpc search term that actually responded to the original user query to the UDV and was stunned at the level of mismatch. For example, I had a phrase/exact match bid for "word1 word2 word3 word4", the user queried the exact term "word1 word2 word3 word4" but Google responded to the query with a broad matched term "word1 word2 wordX" where wordX was barely a synonym but the price point was much higher--not to mention the ad displayed to the user's query was far less relevant because the reponse came from a different ad group. Google does this a lot.

Do you see this mis-matching to increase Search Engine revenues a lot and does your consulting service offer methods of combating this problem of what seems a lot like fraud?

August 31, 2008 8:45 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Eric S: As long as you properly tag links between domains with utmLinker, you should be fine. It should bridge the gap between domains with the right cookie information.

Good luck!

September 2, 2008 3:24 PM

Mike said:

Hi Michael,

I am on the ROI GA Online training.

I have installed the Sleuth Tracking code, but I get "(not set)" when I go check the User Defined data.

I cannot spot what I am doing wrong.

You can view my code in the source of this page:

http://www.enquete-satisfaction.com/

Thanks for your help!
Mike

October 6, 2008 9:06 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Mike: The ga_keyword2.js file must go between the first <script> section of the Google Analytics Tracking Code and the second. You have it before. Please read the article again and be sure to place it in precisely the spot that I indicated. That should fix it for you.

You also should be wary of "smart" or curled quotes showing up in your code. If you use Microsoft Outlook or Word to edit code with quotation marks and paste it into your site, you might end up with a left or a right curled quote (“ or ”) instead of a standard quote ("). Be sure to only use standard quote marks in HTML code.

October 6, 2008 11:03 AM

Mike said:

Michael,

Could it be that I had copied the code from an older version of the article?

I am asking since my code also includes Sleuth() at the end, that the new code doesn't seem to include.

Thanks for your help!
Mike

October 8, 2008 9:52 AM

Eddy said:

This is a great script that I have been using flawlessly for a while now, but for the past month or so, all the keywords within the user defined page are still attached to the Google search query that is after the q variable as in http://www.google.co.uk/search?hl=en&q=keyword1+keyword2&meta=
I dont understand why this has started happening but could do with some advice.

thanks
eddy

October 8, 2008 11:43 AM

Eddy said:

Michael, if not done so already is it possible to add the search queries for the following Google search network partners?
aolsearch.aol.co.uk
www.winbuyer.co.uk
search.babylon.com
www.kellysearch.co.uk
business.shop.ebay.co.uk
search.virginmedia.com
www.hotfroguk.co.uk
uk.ask.com
www.tiscali.co.uk
search1.sky.com
search.mywebsearch.com

there are quite a few more but they generate just one or two visits.

regards
eddy

October 8, 2008 12:35 PM

art said:

Great script. Cant wait to see the results.

October 12, 2008 10:35 PM

Mike said:

Hi Michael,

I got the script to work. However, there are 2 issues:

1) About 20-25% of the visits show as "not set" (I don't use content for that campaign, only search with Google & Search Network).

Can you tell what they could account for?

2) It's a campaign with French keywords and the script doesn't capture the accents properly (whereas GA's Traffic Sources > Keyword Report does). E.g. the word "pr\xE9vention" shows as "prévention".

Is there a way to correct that?

Thanks!
Mike

October 13, 2008 8:04 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Mike: The reason why 20-25% of your visits are "not set" is because the script currently does not account for all of the engines that are a part of the Google search network. We've been working on an update for that, which should be released in the next few days, and should reduce the percentage of "not sets".

We'll also work on getting the accents fixed. Thanks for letting me know!

October 14, 2008 10:42 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Eddy: I'm not really sure what you mean by this. Can you illustrate with a screenshot or a URL?

October 14, 2008 10:45 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Eddy: I've been working on the script, trying to increase the number of search engine query parameters that it recognizes. Thanks for your list, and look for an update over the next few days.

October 14, 2008 10:46 AM

art said:

Great tool! I have started to see the results and they are amazing. 80% of my visits are showing as "not set". Are they all as a results of google parters not being included or because I haven't set utm_medium=ppc for both yahoo and msn ppc traffic? the interesting part is the bulk of our revenue is coming from google partners/or the other engines...the "not set" portion.

Second question..I want to add another domain which is an add-on to the main domain..Do I follow the exact steps for additional domains.

October 15, 2008 12:42 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Art: It could be because you haven't set utm_medium=cpc for Yahoo! and MSN paid traffic. Many Google partners aren't included yet, either, but I'll be posting an update to the script that will contain more of those partners. Keep an eye out on the blog, or subscribe to it to keep up-to-date.

October 15, 2008 10:26 AM

Clikckbank Affiliates said:

Thanks for the update...

October 20, 2008 3:14 PM

Moses Chang said:

Hi, just stumbled upon this tool and immediately created a new Google Analytics account for our website and installed it. Do I lose the ability to track AdWords Campaigns (under the Traffic Sources tab in Google Analytics) once this tool is installed? I also can't find where the search query info are being displayed...

Thanks in advance,
Moses

October 22, 2008 10:46 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Moses: This won't affect your AdWords Campaigns report and won't take away your ability to track campaigns, adgroups, or keywords. To access the exact keyword information, you can either drill down to a specific campaign/adgroup/keyword in the Traffic Sources > AdWords > AdWords Campaigns report and use the Dimension User Defined dropdown.

You can also view all of your exact keyword combinations using the Visitors > User Defined report.

October 22, 2008 11:01 AM

Aidin said:

How does this differ from the filter hack? Which one is better?

November 4, 2008 6:04 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Aidin: Check out my first article when I first created the script for how it differs from Omega's filter hack. I like the script better for the reasons outlined there.

November 5, 2008 1:32 PM

Gavin Doolan said:

Hi there,
I wonder if its possible to concatenate search queries to the user defined value to see data before the last click. (preventing a last click wins scenario)

What I mean is see the string of keywords used before a purchase. Say during the buyer research phase, till the point of purchase?

Obviously there is also the issue of previous campaigns which triggered a visit such as banner / email but I figured this may be the place to mention such an idea.

I've only just started to learn JS myself, perhaps by the time I'm finished reading my current book I'll have an idea on how to do it myself.

Cheers,
Gavin.

November 12, 2008 5:00 AM

Mike said:

Hello Michael,

Are you aware of this Advanced Filter setup that shows the bid keyword + exact search query?

http://www.ga-experts.com/blog/2006/11/how-to-get-detailed-ppc-keyword-data-from-google-analytics/

If so can you comment on the advantages/disadvantages of yours vs. theirs?

One thing that comes to mind is that theirs leaves the User Defined variable free for another utilization.

Thanks!
Mike

November 18, 2008 4:05 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Gavin: It's definitely possible. We've been working on something very similar here. Good luck on your own JS pursuits! Let us know if you post something about this elsewhere and we'll be sure to give you some link love.

November 19, 2008 3:11 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Mike: Definitely. It was Brian's filter that inspired me. The only issue I had with their is how it works on return visits to sites. See my original article for a full explanation.

November 19, 2008 3:13 PM

Aidin said:

Is there a way to implement this script to another profile?The first profile is already using the user defined field by live person chat. Could the two coexist within the same profile?

November 26, 2008 4:03 PM

Bud Gibson said:

How does this play with something like advanced segmentation? I was looking at those reports, and they seem to show what percentage of your search traffic for a given keyword is from paid sources.

The one thing I can see is that I might be able to see how my keywords are broad matching to actual search terms.

December 9, 2008 8:36 AM

Amit said:

Hi Michael,

Awesome post!
I was wondering if combining all the javascript in to a single .js file would be ok?

ON THE WEBPAGE YOUR WOULD PUT:

THE CONTENTS ON MyGA.js WOULD LOOK AS FOLLOWS:

var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));

function noPercent(x)
{
x = unescape(x);
return x.replace(/\+/g," ").replace(/^\s\s*/, '').replace(/\s\s*$/, '');
}

function getRef()
{
ref = document.referrer;
re = /(\?|&)(q|p|query|encquery|qt|terms|rdata|qs|wd|text|szukaj|k|searchExpr|
search_for|string|search_query|searchfor)=([^&]+)/;
searchq = re.exec(ref);
if(searchq) {
searchq[3] = noPercent(searchq[3]);
sleuthTracker._setVar(searchq[3]);
}
else {
sleuthTracker._setVar('Referral: ' + document.referrer);
}
}

function sleuth()
{
if(document.location.search.indexOf("gclid")!=-1||
document.location.search.indexOf("cpc")!=-1) {
getRef();
}
}

var sleuthTracker = _gat._getTracker("UA-1");
sleuthTracker._initData();
sleuth();

var pageTracker = _gat._getTracker("UA-XXXXXX-1");
pageTracker._initData();
pageTracker._trackPageview();

December 24, 2008 4:45 AM

Amit said:

no worries, I figured out why they need to be seperate. Thanks!

December 24, 2008 5:16 AM

rookie said:

The script works great!!
Can somebody help me to modify the script to append the ip of the user next to the search string? This would be invaluable for our statistical analysis. Unfortunately my javascript knowledge is limited. Thanks in advance!

January 4, 2009 6:22 PM

Bud Gibson said:

I just installed this script. An observation: why didn't you name space it? That would eliminate almost all possibilities of javascript conflict which I noticed one commenter remarking. I may do that myself if I get some spare time. It just involves encapsulating your functions in an object with a particular name. You then access the functions with Object.functionName().

January 7, 2009 10:37 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Amit: Yep, there's a reason why they're separate, though you can wrangle the JavaScript in such a way that there's only a single reference for all Google Analytics code, if you wanted to.

January 29, 2009 1:37 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@rookie: Glad the script is working for you!

As pulling IP addresses into Google Analytics actually violates the terms and conditions (and is impossible to do with JavaScript alone), there are currently no plans to add this functionality to the script.

January 29, 2009 1:43 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Bud: We have been testing a version of this script internally that expands on the features and uses object-oriented coding, but you're welcome to post your own.

January 29, 2009 1:50 PM

satin jain said:

but where i put this code..

i m new about this stuff...

please tell me where i have two put this script ...

please tell me...

February 13, 2009 2:55 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@satin jain: Just replace the exiting Google Analytics code, wherever it is on the page, with the one in the box.

February 13, 2009 3:17 PM

Brian Kaldenberg said:

I have installed everything and it appears to be tracking exact keywords correctly.

Problem is when inside analytics if I click the "clicks" tab, none of the clicks, impressions, ctr, cost, etc. data is showing up for dimension user-defined.

I have auto-link tag set to on.

Clicks data shows up for my broad match adgroup, but isn't the point of exact keyword tracking to be able to see clicks data for exact keywords within broad match?

I sure hope it is possible.

February 27, 2009 1:58 AM

Nikki said:

Hi

Is there a way of relating the keyword input to the keyword bid on? e.g. a hybrid of yours and Brian Cliftons PPC terms methods (his override bid term filter). So that a client can see e.g. car parking (car+parking+greater+manchester) using the ga2.js file?

Thanks
Nikki

March 16, 2009 8:54 AM

Richie Rich said:

Hi Michael. I have been successfully using the code here on 6 PPC accounts and the information has proved invaluable - thx so much for this.
However today on 2 of my 6 accounts I have no adwords data showing in my analytics? (and therefor no excat keyword tracking. Have you experienced this before - it may very well be an adwords glitch? Any ideas?

March 25, 2009 8:26 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Richie: No idea why it's not working. Have you checked to make sure that your AdWords linking and cost data is all set up properly?

March 25, 2009 3:20 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Nikki: It seems like it would be possible using filters. Give it a go and let us know how it works out.

March 25, 2009 3:24 PM

Medela Dude said:

Hi Mike, appreciate your work on this and have been using it for a year or 2 now.

Any news on a resolution to the "Not Set" issue?

May 6, 2009 10:51 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Medela Dude: Not yet. There's just a lot of traffic from Google that doesn't match the standard query. We'll definitely keep everyone posted with any updates to the code. Be sure to add the ROI blog to your reader of choice or subscribe via email with the link at the top right.

May 6, 2009 2:27 PM

Salman said:

I have implemented the script. Works fine. It returns the actual KWs in the user defined reports, however there is no goal conversions associated with these KWs although i know that i have made conversions through these KWs.

May 15, 2009 12:17 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Salman: Try drilling down to the keyword level in the Keywords report where you should see your conversions. Then segment by User Defined. What do you see?

May 15, 2009 9:57 AM

Neal said:

Michael, does this keyword filter affect GA ecommerce data? I recently installed it in one of my sites...I see the specific queries from Adwords but don't see conversion data. Our overall ecommerce stats also show $0 revenue right after installing the GA code.

June 19, 2009 7:39 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Neal: It shouldn't affect ecommerce data. What happens when you remove it?

June 22, 2009 11:53 AM

Neal said:

Michael,

We installed the code and all ecommerce data stopped reporting. We were averaging several $30,000 in revenue per day and then it went to $0 after we changed the GA code. Any ideas?

June 24, 2009 9:57 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Neal: Have you tried using the Exact Keyword Tracking script on all pages but your receipt page?

June 25, 2009 4:58 PM

Vince said:

Can someone explain how we can embed this data into our Website forms so the search keywords and PPC data is added to our leads please?

Basically, trying to achieve the same as what Salesforce.com Google adwords integration has with their web-to-lead form.
http://www.semgeek.com/semgeek/2008/03/what-you-need-t.html

July 18, 2009 9:49 AM

neal@akamaiseo.com said:


Michael, are you saying that the modified GA script needs to be on every page of your site except for your confirmation/receipt page?

July 20, 2009 3:51 PM

afzal hanif said:

Really great post, thanx. Right now i'm using the alternate 'filter method' to show the true keywords, however, conversions are still only attributed to the original (adwords) keyword. Perhaps I overlooked, but will this javascript method also show conversions to the true keywords? Hope you can help me, thanx:)

August 6, 2009 3:55 AM

afzal hanif said:

Nice post. I have been using the alternate mode now for a while, but one issue with this: conversions are not attributed to the 'true keywords', but to the keyword defined in adwords. Will this method show actual conversions to the true keywords? Perhaps I missed it but thanx in advance:)!

August 11, 2009 10:44 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Afzal: Yes, it will. One benefit it has over the other method. Just be sure to use the user defined report.

August 19, 2009 10:22 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Neal: Technically it should be on every possible landing page. You can write conditional JavaScript to check and see whether or not this is this case, or you can just put it on every page. Either way works, really.

August 19, 2009 10:32 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Vince: That's a bit more complicated. Justin Cutroni has detailed a method for something similar at his blog. Hope it helps!

August 19, 2009 10:36 AM

Jen said:

thanks Michael and ROIRev. This one gave us substantial savings over a twelve month period.

September 4, 2009 4:51 AM

Guy said:

Great stuff!!
Any way to fix it to show utf-8 keywords?

October 9, 2009 11:26 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Guy: To be honest, I haven't spent a lot of time working on the script. If you'd like to add decoding for utf-8, please feel free! Just let us know of any updates so we can share the wealth.

October 9, 2009 1:24 PM

Riedel Wine Glass said:

So should this script be on every page in the website? sorry newbie question

December 22, 2009 3:18 PM

Wytze said:

Thanks a million Michael,

Your script has made our year! Like somebody else mentioned earlier. This information is invaluable! Only running for a couple of days and I've already seen so many incorrect queries!

I do have a question though, is there a way to associate costs to the queries like you see with Search Query reports in Adwords?

Thanks again so much and have an early merry christmas! :)

December 23, 2009 7:00 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Riedel: Yes, put it on every page of your site. It should replace the standard Google Analytics Tracking Code.

January 4, 2010 5:55 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Wytze: No, there's not currently a way to associate costs with the queries. We typically just use the SQR in AdWords to do that.

January 4, 2010 5:57 PM

David Ogletree said:

I used to work at a ppc agency and our Google rep gave me a filter that let me track search partners. I did not save the filter and I don't have access to that account anymore. I can't seem to find how to do this again. Can you make a filter that does this?

January 12, 2010 9:46 AM

GregBB said:

What would be the reasons to favor the ga.js update to view actual search phrases in comparison to applying the "Override Bid Term" filters? Is the result the same? One obvious reason is that you can instantly apply it to all profiles, which could also be a disincentive if you would like to have more flexibility. Would appreciate your thoughts. Thanks!

February 4, 2010 8:01 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@David: You can add a query parameter to your destination URLs and then use the special AdWords macro {placement} to insert the URL that the ad was displayed on, like so:

www.mysite.com?site={placement}

Then you can use something like Filters, Site Search or Custom Variables to pull that data out and put it into a Google Analytics report.

March 6, 2010 4:18 PM

Kevin Joyner said:

Hi Michael

I seem to have gathered the impression from somewhere that there are plans ultimately to deprecate the GA user defined variable, and that we should use custom variables where possible.

Would it be worthwhile to adapt your Keyword Sleuth script to use custom variables? If so, I don't suppose you've done that, have you? :-)

Many thanks

Kevin

April 20, 2010 9:00 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Kevin: We have, and it works just fine. Look for an article about it in the near future.

April 20, 2010 11:10 AM

Sandra said:

Ok...pardon the moron. I have read this entire thread and just want to make sure I understand completely b4 I implement the code.

1. I literally just REPLACE the code on my sites with the one up top u provide (obviously changing the profile numbers)?

2. Do I have to also upload this ga_keyword2.js file? If so, why?

Thanks so much - really looking 4ward to taking it for a test drive!

S

May 19, 2010 3:55 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Sandra: Yes, replace the code on your site with the one above. And, yes, you do need to upload the file. Why? Because that's where all the code that grabs the search query is.

May 25, 2010 9:42 AM

Eric said:

Hi Michael,

I wanted to thank you for this wonderful tool. We've been using it for almost 2 years and its benefit has been significant.

Yesterday, I upgraded my site to the new asynchronous GATC code but wasn't quite sure how to integrate ga_keyword.js so I took my best shot as shown below. No luck--the user defined value data has disappeared.

Actually, there are two problems here. Whenever I originally set up the 'traditional' GATC code with the two additional lines for cross-domain tracking, the UDV info would disappeared. We decided knowing what the original queries were outweighed cross domain tracking so we just left out the

pageTracker._setDomainName('none');
pageTracker._setAllowLinker(true);

lines and lived with the compromise. This time I included the asynchronous equivalent for cross domain hoping it would work but no luck.

_gaq.push(['_setDomainName', 'none']);
_gaq.push(['_setAllowLinker', true]);

So I've changed too many variables to know what the real problem is, but if this is a no-brainer for you, would you please point out my error. Alternately, I can go back and remove the cross domain asynchronous lines to try and isolate the cause and effect and see what happens.

Also noticed an early post about deprecating the _setVar() function and an upcoming post about that? Perhaps that post might be nearby?

Would be grateful for any help.

Eric.

Current Attempt:

<!--
<head>

<script src="ga_keyword.js" type="text/javascript"></script>

<script type="text/javascript">

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-123456-1']);

_gaq.push(['_setDomainName', 'none']);
_gaq.push(['_setAllowLinker', true]);

_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

</script>

</head>
-->

July 7, 2010 9:00 AM

Darrell said:

Google Adwords lets me generate a report of keyphrases typed that caused ads to show up and wheter they generated clicks or not. These are phrases typed during the search, including searches on other sites, not just the keyword that match the ad. I can then see phrases generating clicks that I don't like the words that are in them, then ad those to my negative keywords. Is this something new that was not available in 2008 when this ga_keyword script was created?

September 8, 2010 5:52 PM

George Strait Tickets said:

Then you can use something like Filters, Site Search or Custom Variables to pull that data out and put it into a Google Analytics report.

September 23, 2010 5:58 AM

Christina said:

I used to work at a ppc agency and our Google rep gave me a filter that let me track search partners. I did not save the filter and I don't have access to that account anymore. I can't seem to find how to do this again. Can you make a filter that does this

October 26, 2010 8:58 AM

PPC Whiz said:

This stuff is great! Keep up the good work team, I really appreciate you sharing this with the community. You are an excellent resource for us PPC guys out there looking to maximize our spend.
My clients will thank you!

February 14, 2008 3:25 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@PPC Whiz: Glad we could help out! Definitely keep posted here on any additions or updates, and like I said in my post, our own team will be posting some of their tips and tricks in the coming weeks.

February 14, 2008 4:22 PM

Jesse DaCosta said:

Hey Michael,

Thanks for the update, have been on the lookout for it! I've tried another method from another blog but that doesn't seem to work, at least for me, so now I've updated to the new code I'm going to test this out.

Thanks again!

February 14, 2008 4:37 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Jesse: Great! Let me know how it works for you. We're always trying to improve it.

February 14, 2008 5:54 PM

Christian Martin said:

Thanks for updating the ga.js script with this! I only saw the original change for the old urchin code yesterday after your webinar. I've already changed the GA code on both our site and looking forward to seeing the results in the coming days.

I do have a question... In the Traffic Sources::Keywords section, their are toggles for Show: total | paid | non-paid and then the Segment listbox.

On first glance, it would seem GA is providing everything without the script. Am I being simplistic in my cursory look?

Thanks again!

February 14, 2008 7:06 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Christian: Unfortunately, the Keywords report will only show you the bid terms for your paid search. Basically, it will show you the keyword phrase that you bid upon, but not the one that visitors actually typed into the search engine. Hope that makes sense.

February 15, 2008 9:32 AM

Dave Cardwell said:

Thanks for updating this script and sharing it with the community.

I'm curious - why the "UA-1" in this line of the script:
_gat._getTracker("UA-1");

February 15, 2008 11:51 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Dave: It's just a precaution, due to the way that setVar operates, and we've found that it leads to more accurate usage stats.

February 15, 2008 1:57 PM

Searchquant said:

Doesn't it seem strange that Google wouldn't make this a feature in G Analytics early on? It's clear any smart marketer's gonna want to know which queries within phrase or broad matched keywords are working and not working.

Google gets 70% of its revenue from phrase and broad match.

February 15, 2008 4:53 PM

Sonja Bakker said:

Hi,

This quiet cool. I already saw that the previous script wasn't working anymore. Going to try this one now!

February 18, 2008 11:27 AM

Julien Raby said:

Hi Michael,

thanks a lot for this new version of the script, I was using the old filter hacks but it doesn't work anymore...

One question: the script as it is now doesn't seem to work if I manually tag my link (I almost always tag my links instead of using the auto-tagging to gain more control over the utm_campaign variable...) so I was wondering if there were a quick fix fo manual link tagger like myself?

Thanks again,
Julien

February 19, 2008 6:54 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Julien: While we definitely don't recommend that you manually tag AdWords ads (it causes problems when Analytics links up the data between your two accounts), this method should work for manually tagged links, so long as those links are tagged with utm_medium=cpc and the visits are coming from a search engine with a plainly visible search query in the URL (e.g., q=search+query, p=search+query, query=search+query).

February 22, 2008 3:28 PM

Chris Bradley said:

Thanks for this, I just tried the other method last week and didn't get it to work so this comes at a great time for me but I do have one question..

Should I upload the script to my root directory?

February 24, 2008 2:41 PM

Shawn Purtell, Senior Web Analytics Engineer Author Profile Page said:

@Chris:

You can upload the file wherever you like. Most websites have a specific place where scripts are stored, but it's different for everybody. The important thing is to make sure the call to the .js script is pointing to the right place.

February 25, 2008 9:29 AM

Charles Meaden said:

The actual ga_keyword2.js script contains the following lines


var pageTracker = _gat._getTracker("UA-XXXXXX-X");

The page says not to edit the script, but should I be changing the [yoursitehere] and UA-XXXX lines so that they correspond to our tracking codes?

March 17, 2008 10:40 AM

Jeremy Aube, Director of Engineering Author Profile Page said:

@Charles: Those lines are just a re-iteration of the installation instructions as given in the article. They are just comments, so you don't need to change it.

March 18, 2008 10:48 AM

Charles Meaden said:

Jeremy,

Thank you. Two more questions if I may.

1. Does it make any difference if I have amended the code to use our details
2. Can I use remove the commented section from the ga_keyword2.js file then

March 19, 2008 6:55 AM

Jeremy Aube, Director of Engineering Author Profile Page said:

@Charles: You really shouldn't be making any changes to the javascript file. If you're just making changes to or removing the comment section, that won't affect the functionality of the script, but it would be best to leave it as is. Then anyone who looks at the script will have the version number, author, general instructions (rather than specific to a single site's setup), and when it was last modified. Any changes to the script itself could negatively affect its functionality. Michael has written this script very precisely so that it needs no modification to work with your site.

March 19, 2008 9:52 AM

Ron said:

ok, I really want to get this data from my analytics and I have upgraded to ga and installed the tracking code...but I can't for the life of me understand where I find the detailed keyword search data in my analytics account. Can someone point me in the right direction?

April 2, 2008 4:21 PM

Jeremy Aube, Director of Engineering Author Profile Page said:

@Ron: The Exact Keyword Data for the site will be in the User Defined Report. You can also segment various reports by the User Defined Variable to see this information for specific visitor traffic segments. See Michael's previous post for more information.

April 2, 2008 4:39 PM

Ron said:

So if I look in the tab "Visitor/UserDefined" and all I see under the user defined values is "not set" then it's safe to assume I screwed up in inserting the tracking code?

April 2, 2008 5:35 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Ron: Well, it either means that you screwed up, or that you don't have any paid search traffic coming into your site. The traffic has to be auto-tagged AdWords clicks or manually tagged clicks with utm_medium=cpc.

Good luck!

April 3, 2008 10:59 AM

Ryan said:

Okay, I feel like an idiot.

The code checks out fine. Analytics is otherwise tracking fine. And I am getting my adwords PPC traffic to come up.

But STILL, I'm only getting "not set".

Is there something I'm missing? Maybe something obscenely obvious?

Thanks so much!

June 3, 2008 10:06 AM

Ryan said:

Yup. I'm definitely an idiot.

1. Didn't change the .js src path.

2. Didn't upload the .js file.

June 3, 2008 10:34 AM

Eric said:

Thanks for making these scripts. I put them on my site about a week ago, and the info has been very valuable.

Unfortunately, about 50% of the data comes back as (not set) and a slightly better return of only 33% on Yahoo. I don't have my account autotagged for various reasons, but every keyword has it's own URL with utm_medium=cpc. Is this the normal capture for the script or perhaps I have done something wrong or does the order of the utm_ variables in the search string matter. Currently I set the source, medium, campaign and then the term.

Thanks again for this wonderful tool.

June 10, 2008 2:36 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Eric: Well, content network will never display a search query, and some of the search partner sites don't format the search query in the same way that Google does. 50% is about the norm for what I see.

If you can find the search network sites that your ads are running and provide them, I may be able to expand the script to use their search queries.

June 10, 2008 4:27 PM

Daniel Waisberg said:

Hi Michael,

Thank you very much for the feature it is wonderful.

I was wondering if this code can work together with the one created by John Henson from LunaMetrics: Stuff More Than One Value into GA\x92s User Defined Segment . If so, this would solve the issue of using other User Defined Variables together with it.

Thank you again.

June 22, 2008 4:05 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Daniel: I don't see why the two scripts wouldn't play nice together. :) It may require some modifications to the JavaScript. Give it a shot and let us know how it works out.

June 24, 2008 8:24 AM

Eran Malloch said:

Hi Michael,

I REALLY REALLY REALLY need this tool to work (great idea and thanks to all who developed it), but unfortunately, whenever I add it to a site created by our webdesign partners, it somehow interferes with the script that creates their drop-down menu system, and the menu system stops working... :(

This has happened on 2 seperate sites now, and obviously we have to remove your script because a non-working menu system just aint gonna cut it. ;)

I'm guessing if this is happening to me, there are probably others it is happening to as well, but perhaps they haven't bothered to contact you and mention it.

ANY help you (or anyone else reading this comment) can provide with this issue would be GREATLY appreciated. I am happy to email you the offending site urls, etc.

Thanks in advance for your time, and I really do appreciate your efforts to provide this vital tool (and bah humbug to Google for NOT providing it) ;)


Eran Malloch
WCR Internet Marketing
Perth, Western Australia

July 11, 2008 2:22 AM

wil said:

How do I create a report that shows side-by-side the keyword in the AdWords campaign that was triggered along with the user defined variable (the search term). Right now, under traffic sources, I can see one or the other.

Thanks,

Wil

July 12, 2008 2:27 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Eran: I'd check to make sure that none of the functions from the menu system interfere with the keyword script. Beyond that, I don't see why it would cause any problems. Because of the sheer number of setups and JavaScript present on websites, there's no possible way we can troubleshoot each individual issue with the script, but if you have any additional comments on precisely what is going on (error messages, etc.), then maybe we can help out.

July 21, 2008 1:29 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Wil: There is no such report, but you could create a new profile with an Advanced Filter that plugs the User Defined field into the Campaign Term field. Just cram 'em both together, and that way when you look at your keywords list, you would see:

"bid term (search term)"

This will mean that cost and click data for your AdWords Campaigns keyword report will not match up properly, thus the reason why I recommend creating an additional profile.

Hope that helps.

July 21, 2008 1:36 PM

Eric Werner said:

Hi and thanks! One quick question, what does this do?

pageTracker._initData();

This line isn't in the code that Google gave me and you didn't mention anything about it in the post so I wanted to check.

Thanks!

August 8, 2008 12:18 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Eric: pageTracker._initData() is a deprecated function that was previously required before running the Google Analytics pageTracker. You can get rid of it or keep it in; entirely up to you.

August 8, 2008 1:52 PM

Jason said:

Michael - I've modified a function in the ga_keyword2.js code that I find quite useful re: more accurate stats gathering:

function noPercent(x)
{
x = unescape(x);
x = x.replace(/\+/g," ").replace(/^\s\s*/, '').replace(/\s\s*$/, '');
return x.toLowerCase(); // added feature
}


this basically groups all upper & lower case variations so that I get an accurate picture of the number of people using a particular word or phrase. Great script!

August 14, 2008 9:44 PM

Ricky said:

I think that this script looks great, and I have just updated the script on our site to check it out.

Though one question still remains, how does this differ from the report you get out of Adwords that shows you which search results that triggered your adwords to show and generate a click?

Thanks!

August 19, 2008 8:14 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Ricky: Check out my co-worker Mark Curtis' article on the Keyword Sleuth script versus the AdWords Search Query Performance Report for the answer to your question.

August 19, 2008 10:17 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Jason: Thanks for the info. You could also use a lowercase filter inside of Google Analytics if you don't want to modify the code (if, for instance, it's already installed on your site).

August 19, 2008 10:19 AM

Eric S said:

Michael, thanks again for this wonderful script. I recently upgraded to the new tracking code and the script worked fine. Unfortunately, my 'check-out' is handled by a third party that is still running the legacy script and they are hesitant to upgrade. Note that their legacy script also has

_udn="none";
_ulink=1;

in the legacy code to enable cross-domain tracking.

So, I downgraded back to the legacy code and added the two lines for cross-domain tracking code that I had not used before, and the next day all of my User Defined Value data was missing. So I deleted the

_udn="none";
_ulink=1;

lines and it immediately returned but this left me without the cross domain tracking I had hoped to gain. Note that the User Defined Value came through just fine in the ga.js version except the link was broken across the domains due to code incompatability. Any suggestions for getting the legacy version to work cross-domain. I noticed that the slueth(); function was in the legacy code on your first blog in 07 but not the more recent blog. Might this be part of it?

On a completely separate issue, I appended the cpc search term that actually responded to the original user query to the UDV and was stunned at the level of mismatch. For example, I had a phrase/exact match bid for "word1 word2 word3 word4", the user queried the exact term "word1 word2 word3 word4" but Google responded to the query with a broad matched term "word1 word2 wordX" where wordX was barely a synonym but the price point was much higher--not to mention the ad displayed to the user's query was far less relevant because the reponse came from a different ad group. Google does this a lot.

Do you see this mis-matching to increase Search Engine revenues a lot and does your consulting service offer methods of combating this problem of what seems a lot like fraud?

August 31, 2008 8:45 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Eric S: As long as you properly tag links between domains with utmLinker, you should be fine. It should bridge the gap between domains with the right cookie information.

Good luck!

September 2, 2008 3:24 PM

Mike said:

Hi Michael,

I am on the ROI GA Online training.

I have installed the Sleuth Tracking code, but I get "(not set)" when I go check the User Defined data.

I cannot spot what I am doing wrong.

You can view my code in the source of this page:

http://www.enquete-satisfaction.com/

Thanks for your help!
Mike

October 6, 2008 9:06 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Mike: The ga_keyword2.js file must go between the first <script> section of the Google Analytics Tracking Code and the second. You have it before. Please read the article again and be sure to place it in precisely the spot that I indicated. That should fix it for you.

You also should be wary of "smart" or curled quotes showing up in your code. If you use Microsoft Outlook or Word to edit code with quotation marks and paste it into your site, you might end up with a left or a right curled quote (“ or ”) instead of a standard quote ("). Be sure to only use standard quote marks in HTML code.

October 6, 2008 11:03 AM

Mike said:

Michael,

Could it be that I had copied the code from an older version of the article?

I am asking since my code also includes Sleuth() at the end, that the new code doesn't seem to include.

Thanks for your help!
Mike

October 8, 2008 9:52 AM

Eddy said:

This is a great script that I have been using flawlessly for a while now, but for the past month or so, all the keywords within the user defined page are still attached to the Google search query that is after the q variable as in http://www.google.co.uk/search?hl=en&q=keyword1+keyword2&meta=
I dont understand why this has started happening but could do with some advice.

thanks
eddy

October 8, 2008 11:43 AM

Eddy said:

Michael, if not done so already is it possible to add the search queries for the following Google search network partners?
aolsearch.aol.co.uk
www.winbuyer.co.uk
search.babylon.com
www.kellysearch.co.uk
business.shop.ebay.co.uk
search.virginmedia.com
www.hotfroguk.co.uk
uk.ask.com
www.tiscali.co.uk
search1.sky.com
search.mywebsearch.com

there are quite a few more but they generate just one or two visits.

regards
eddy

October 8, 2008 12:35 PM

art said:

Great script. Cant wait to see the results.

October 12, 2008 10:35 PM

Mike said:

Hi Michael,

I got the script to work. However, there are 2 issues:

1) About 20-25% of the visits show as "not set" (I don't use content for that campaign, only search with Google & Search Network).

Can you tell what they could account for?

2) It's a campaign with French keywords and the script doesn't capture the accents properly (whereas GA's Traffic Sources > Keyword Report does). E.g. the word "pr\xE9vention" shows as "prévention".

Is there a way to correct that?

Thanks!
Mike

October 13, 2008 8:04 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Mike: The reason why 20-25% of your visits are "not set" is because the script currently does not account for all of the engines that are a part of the Google search network. We've been working on an update for that, which should be released in the next few days, and should reduce the percentage of "not sets".

We'll also work on getting the accents fixed. Thanks for letting me know!

October 14, 2008 10:42 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Eddy: I'm not really sure what you mean by this. Can you illustrate with a screenshot or a URL?

October 14, 2008 10:45 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Eddy: I've been working on the script, trying to increase the number of search engine query parameters that it recognizes. Thanks for your list, and look for an update over the next few days.

October 14, 2008 10:46 AM

art said:

Great tool! I have started to see the results and they are amazing. 80% of my visits are showing as "not set". Are they all as a results of google parters not being included or because I haven't set utm_medium=ppc for both yahoo and msn ppc traffic? the interesting part is the bulk of our revenue is coming from google partners/or the other engines...the "not set" portion.

Second question..I want to add another domain which is an add-on to the main domain..Do I follow the exact steps for additional domains.

October 15, 2008 12:42 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Art: It could be because you haven't set utm_medium=cpc for Yahoo! and MSN paid traffic. Many Google partners aren't included yet, either, but I'll be posting an update to the script that will contain more of those partners. Keep an eye out on the blog, or subscribe to it to keep up-to-date.

October 15, 2008 10:26 AM

Clikckbank Affiliates said:

Thanks for the update...

October 20, 2008 3:14 PM

Moses Chang said:

Hi, just stumbled upon this tool and immediately created a new Google Analytics account for our website and installed it. Do I lose the ability to track AdWords Campaigns (under the Traffic Sources tab in Google Analytics) once this tool is installed? I also can't find where the search query info are being displayed...

Thanks in advance,
Moses

October 22, 2008 10:46 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Moses: This won't affect your AdWords Campaigns report and won't take away your ability to track campaigns, adgroups, or keywords. To access the exact keyword information, you can either drill down to a specific campaign/adgroup/keyword in the Traffic Sources > AdWords > AdWords Campaigns report and use the Dimension User Defined dropdown.

You can also view all of your exact keyword combinations using the Visitors > User Defined report.

October 22, 2008 11:01 AM

Aidin said:

How does this differ from the filter hack? Which one is better?

November 4, 2008 6:04 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Aidin: Check out my first article when I first created the script for how it differs from Omega's filter hack. I like the script better for the reasons outlined there.

November 5, 2008 1:32 PM

Gavin Doolan said:

Hi there,
I wonder if its possible to concatenate search queries to the user defined value to see data before the last click. (preventing a last click wins scenario)

What I mean is see the string of keywords used before a purchase. Say during the buyer research phase, till the point of purchase?

Obviously there is also the issue of previous campaigns which triggered a visit such as banner / email but I figured this may be the place to mention such an idea.

I've only just started to learn JS myself, perhaps by the time I'm finished reading my current book I'll have an idea on how to do it myself.

Cheers,
Gavin.

November 12, 2008 5:00 AM

Mike said:

Hello Michael,

Are you aware of this Advanced Filter setup that shows the bid keyword + exact search query?

http://www.ga-experts.com/blog/2006/11/how-to-get-detailed-ppc-keyword-data-from-google-analytics/

If so can you comment on the advantages/disadvantages of yours vs. theirs?

One thing that comes to mind is that theirs leaves the User Defined variable free for another utilization.

Thanks!
Mike

November 18, 2008 4:05 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Gavin: It's definitely possible. We've been working on something very similar here. Good luck on your own JS pursuits! Let us know if you post something about this elsewhere and we'll be sure to give you some link love.

November 19, 2008 3:11 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Mike: Definitely. It was Brian's filter that inspired me. The only issue I had with their is how it works on return visits to sites. See my original article for a full explanation.

November 19, 2008 3:13 PM

Aidin said:

Is there a way to implement this script to another profile?The first profile is already using the user defined field by live person chat. Could the two coexist within the same profile?

November 26, 2008 4:03 PM

Bud Gibson said:

How does this play with something like advanced segmentation? I was looking at those reports, and they seem to show what percentage of your search traffic for a given keyword is from paid sources.

The one thing I can see is that I might be able to see how my keywords are broad matching to actual search terms.

December 9, 2008 8:36 AM

Amit said:

Hi Michael,

Awesome post!
I was wondering if combining all the javascript in to a single .js file would be ok?

ON THE WEBPAGE YOUR WOULD PUT:

THE CONTENTS ON MyGA.js WOULD LOOK AS FOLLOWS:

var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));

function noPercent(x)
{
x = unescape(x);
return x.replace(/\+/g," ").replace(/^\s\s*/, '').replace(/\s\s*$/, '');
}

function getRef()
{
ref = document.referrer;
re = /(\?|&)(q|p|query|encquery|qt|terms|rdata|qs|wd|text|szukaj|k|searchExpr|
search_for|string|search_query|searchfor)=([^&]+)/;
searchq = re.exec(ref);
if(searchq) {
searchq[3] = noPercent(searchq[3]);
sleuthTracker._setVar(searchq[3]);
}
else {
sleuthTracker._setVar('Referral: ' + document.referrer);
}
}

function sleuth()
{
if(document.location.search.indexOf("gclid")!=-1||
document.location.search.indexOf("cpc")!=-1) {
getRef();
}
}

var sleuthTracker = _gat._getTracker("UA-1");
sleuthTracker._initData();
sleuth();

var pageTracker = _gat._getTracker("UA-XXXXXX-1");
pageTracker._initData();
pageTracker._trackPageview();

December 24, 2008 4:45 AM

Amit said:

no worries, I figured out why they need to be seperate. Thanks!

December 24, 2008 5:16 AM

rookie said:

The script works great!!
Can somebody help me to modify the script to append the ip of the user next to the search string? This would be invaluable for our statistical analysis. Unfortunately my javascript knowledge is limited. Thanks in advance!

January 4, 2009 6:22 PM

Bud Gibson said:

I just installed this script. An observation: why didn't you name space it? That would eliminate almost all possibilities of javascript conflict which I noticed one commenter remarking. I may do that myself if I get some spare time. It just involves encapsulating your functions in an object with a particular name. You then access the functions with Object.functionName().

January 7, 2009 10:37 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Amit: Yep, there's a reason why they're separate, though you can wrangle the JavaScript in such a way that there's only a single reference for all Google Analytics code, if you wanted to.

January 29, 2009 1:37 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@rookie: Glad the script is working for you!

As pulling IP addresses into Google Analytics actually violates the terms and conditions (and is impossible to do with JavaScript alone), there are currently no plans to add this functionality to the script.

January 29, 2009 1:43 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Bud: We have been testing a version of this script internally that expands on the features and uses object-oriented coding, but you're welcome to post your own.

January 29, 2009 1:50 PM

satin jain said:

but where i put this code..

i m new about this stuff...

please tell me where i have two put this script ...

please tell me...

February 13, 2009 2:55 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@satin jain: Just replace the exiting Google Analytics code, wherever it is on the page, with the one in the box.

February 13, 2009 3:17 PM

Brian Kaldenberg said:

I have installed everything and it appears to be tracking exact keywords correctly.

Problem is when inside analytics if I click the "clicks" tab, none of the clicks, impressions, ctr, cost, etc. data is showing up for dimension user-defined.

I have auto-link tag set to on.

Clicks data shows up for my broad match adgroup, but isn't the point of exact keyword tracking to be able to see clicks data for exact keywords within broad match?

I sure hope it is possible.

February 27, 2009 1:58 AM

Nikki said:

Hi

Is there a way of relating the keyword input to the keyword bid on? e.g. a hybrid of yours and Brian Cliftons PPC terms methods (his override bid term filter). So that a client can see e.g. car parking (car+parking+greater+manchester) using the ga2.js file?

Thanks
Nikki

March 16, 2009 8:54 AM

Richie Rich said:

Hi Michael. I have been successfully using the code here on 6 PPC accounts and the information has proved invaluable - thx so much for this.
However today on 2 of my 6 accounts I have no adwords data showing in my analytics? (and therefor no excat keyword tracking. Have you experienced this before - it may very well be an adwords glitch? Any ideas?

March 25, 2009 8:26 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Richie: No idea why it's not working. Have you checked to make sure that your AdWords linking and cost data is all set up properly?

March 25, 2009 3:20 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Nikki: It seems like it would be possible using filters. Give it a go and let us know how it works out.

March 25, 2009 3:24 PM

Medela Dude said:

Hi Mike, appreciate your work on this and have been using it for a year or 2 now.

Any news on a resolution to the "Not Set" issue?

May 6, 2009 10:51 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Medela Dude: Not yet. There's just a lot of traffic from Google that doesn't match the standard query. We'll definitely keep everyone posted with any updates to the code. Be sure to add the ROI blog to your reader of choice or subscribe via email with the link at the top right.

May 6, 2009 2:27 PM

Salman said:

I have implemented the script. Works fine. It returns the actual KWs in the user defined reports, however there is no goal conversions associated with these KWs although i know that i have made conversions through these KWs.

May 15, 2009 12:17 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Salman: Try drilling down to the keyword level in the Keywords report where you should see your conversions. Then segment by User Defined. What do you see?

May 15, 2009 9:57 AM

Neal said:

Michael, does this keyword filter affect GA ecommerce data? I recently installed it in one of my sites...I see the specific queries from Adwords but don't see conversion data. Our overall ecommerce stats also show $0 revenue right after installing the GA code.

June 19, 2009 7:39 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Neal: It shouldn't affect ecommerce data. What happens when you remove it?

June 22, 2009 11:53 AM

Neal said:

Michael,

We installed the code and all ecommerce data stopped reporting. We were averaging several $30,000 in revenue per day and then it went to $0 after we changed the GA code. Any ideas?

June 24, 2009 9:57 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Neal: Have you tried using the Exact Keyword Tracking script on all pages but your receipt page?

June 25, 2009 4:58 PM

Vince said:

Can someone explain how we can embed this data into our Website forms so the search keywords and PPC data is added to our leads please?

Basically, trying to achieve the same as what Salesforce.com Google adwords integration has with their web-to-lead form.
http://www.semgeek.com/semgeek/2008/03/what-you-need-t.html

July 18, 2009 9:49 AM

neal@akamaiseo.com said:


Michael, are you saying that the modified GA script needs to be on every page of your site except for your confirmation/receipt page?

July 20, 2009 3:51 PM

afzal hanif said:

Really great post, thanx. Right now i'm using the alternate 'filter method' to show the true keywords, however, conversions are still only attributed to the original (adwords) keyword. Perhaps I overlooked, but will this javascript method also show conversions to the true keywords? Hope you can help me, thanx:)

August 6, 2009 3:55 AM

afzal hanif said:

Nice post. I have been using the alternate mode now for a while, but one issue with this: conversions are not attributed to the 'true keywords', but to the keyword defined in adwords. Will this method show actual conversions to the true keywords? Perhaps I missed it but thanx in advance:)!

August 11, 2009 10:44 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Afzal: Yes, it will. One benefit it has over the other method. Just be sure to use the user defined report.

August 19, 2009 10:22 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Neal: Technically it should be on every possible landing page. You can write conditional JavaScript to check and see whether or not this is this case, or you can just put it on every page. Either way works, really.

August 19, 2009 10:32 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Vince: That's a bit more complicated. Justin Cutroni has detailed a method for something similar at his blog. Hope it helps!

August 19, 2009 10:36 AM

Jen said:

thanks Michael and ROIRev. This one gave us substantial savings over a twelve month period.

September 4, 2009 4:51 AM

Guy said:

Great stuff!!
Any way to fix it to show utf-8 keywords?

October 9, 2009 11:26 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Guy: To be honest, I haven't spent a lot of time working on the script. If you'd like to add decoding for utf-8, please feel free! Just let us know of any updates so we can share the wealth.

October 9, 2009 1:24 PM

Riedel Wine Glass said:

So should this script be on every page in the website? sorry newbie question

December 22, 2009 3:18 PM

Wytze said:

Thanks a million Michael,

Your script has made our year! Like somebody else mentioned earlier. This information is invaluable! Only running for a couple of days and I've already seen so many incorrect queries!

I do have a question though, is there a way to associate costs to the queries like you see with Search Query reports in Adwords?

Thanks again so much and have an early merry christmas! :)

December 23, 2009 7:00 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Riedel: Yes, put it on every page of your site. It should replace the standard Google Analytics Tracking Code.

January 4, 2010 5:55 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Wytze: No, there's not currently a way to associate costs with the queries. We typically just use the SQR in AdWords to do that.

January 4, 2010 5:57 PM

David Ogletree said:

I used to work at a ppc agency and our Google rep gave me a filter that let me track search partners. I did not save the filter and I don't have access to that account anymore. I can't seem to find how to do this again. Can you make a filter that does this?

January 12, 2010 9:46 AM

GregBB said:

What would be the reasons to favor the ga.js update to view actual search phrases in comparison to applying the "Override Bid Term" filters? Is the result the same? One obvious reason is that you can instantly apply it to all profiles, which could also be a disincentive if you would like to have more flexibility. Would appreciate your thoughts. Thanks!

February 4, 2010 8:01 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@David: You can add a query parameter to your destination URLs and then use the special AdWords macro {placement} to insert the URL that the ad was displayed on, like so:

www.mysite.com?site={placement}

Then you can use something like Filters, Site Search or Custom Variables to pull that data out and put it into a Google Analytics report.

March 6, 2010 4:18 PM

Kevin Joyner said:

Hi Michael

I seem to have gathered the impression from somewhere that there are plans ultimately to deprecate the GA user defined variable, and that we should use custom variables where possible.

Would it be worthwhile to adapt your Keyword Sleuth script to use custom variables? If so, I don't suppose you've done that, have you? :-)

Many thanks

Kevin

April 20, 2010 9:00 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Kevin: We have, and it works just fine. Look for an article about it in the near future.

April 20, 2010 11:10 AM

Sandra said:

Ok...pardon the moron. I have read this entire thread and just want to make sure I understand completely b4 I implement the code.

1. I literally just REPLACE the code on my sites with the one up top u provide (obviously changing the profile numbers)?

2. Do I have to also upload this ga_keyword2.js file? If so, why?

Thanks so much - really looking 4ward to taking it for a test drive!

S

May 19, 2010 3:55 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Sandra: Yes, replace the code on your site with the one above. And, yes, you do need to upload the file. Why? Because that's where all the code that grabs the search query is.

May 25, 2010 9:42 AM

Eric said:

Hi Michael,

I wanted to thank you for this wonderful tool. We've been using it for almost 2 years and its benefit has been significant.

Yesterday, I upgraded my site to the new asynchronous GATC code but wasn't quite sure how to integrate ga_keyword.js so I took my best shot as shown below. No luck--the user defined value data has disappeared.

Actually, there are two problems here. Whenever I originally set up the 'traditional' GATC code with the two additional lines for cross-domain tracking, the UDV info would disappeared. We decided knowing what the original queries were outweighed cross domain tracking so we just left out the

pageTracker._setDomainName('none');
pageTracker._setAllowLinker(true);

lines and lived with the compromise. This time I included the asynchronous equivalent for cross domain hoping it would work but no luck.

_gaq.push(['_setDomainName', 'none']);
_gaq.push(['_setAllowLinker', true]);

So I've changed too many variables to know what the real problem is, but if this is a no-brainer for you, would you please point out my error. Alternately, I can go back and remove the cross domain asynchronous lines to try and isolate the cause and effect and see what happens.

Also noticed an early post about deprecating the _setVar() function and an upcoming post about that? Perhaps that post might be nearby?

Would be grateful for any help.

Eric.

Current Attempt:

<!--
<head>

<script src="ga_keyword.js" type="text/javascript"></script>

<script type="text/javascript">

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-123456-1']);

_gaq.push(['_setDomainName', 'none']);
_gaq.push(['_setAllowLinker', true]);

_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

</script>

</head>
-->

July 7, 2010 9:00 AM

Darrell said:

Google Adwords lets me generate a report of keyphrases typed that caused ads to show up and wheter they generated clicks or not. These are phrases typed during the search, including searches on other sites, not just the keyword that match the ad. I can then see phrases generating clicks that I don't like the words that are in them, then ad those to my negative keywords. Is this something new that was not available in 2008 when this ga_keyword script was created?

September 8, 2010 5:52 PM

George Strait Tickets said:

Then you can use something like Filters, Site Search or Custom Variables to pull that data out and put it into a Google Analytics report.

September 23, 2010 5:58 AM

Christina said:

I used to work at a ppc agency and our Google rep gave me a filter that let me track search partners. I did not save the filter and I don't have access to that account anymore. I can't seem to find how to do this again. Can you make a filter that does this

October 26, 2010 8:58 AM

PPC Whiz said:

This stuff is great! Keep up the good work team, I really appreciate you sharing this with the community. You are an excellent resource for us PPC guys out there looking to maximize our spend.
My clients will thank you!

February 14, 2008 3:25 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@PPC Whiz: Glad we could help out! Definitely keep posted here on any additions or updates, and like I said in my post, our own team will be posting some of their tips and tricks in the coming weeks.

February 14, 2008 4:22 PM

Jesse DaCosta said:

Hey Michael,

Thanks for the update, have been on the lookout for it! I've tried another method from another blog but that doesn't seem to work, at least for me, so now I've updated to the new code I'm going to test this out.

Thanks again!

February 14, 2008 4:37 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Jesse: Great! Let me know how it works for you. We're always trying to improve it.

February 14, 2008 5:54 PM

Christian Martin said:

Thanks for updating the ga.js script with this! I only saw the original change for the old urchin code yesterday after your webinar. I've already changed the GA code on both our site and looking forward to seeing the results in the coming days.

I do have a question... In the Traffic Sources::Keywords section, their are toggles for Show: total | paid | non-paid and then the Segment listbox.

On first glance, it would seem GA is providing everything without the script. Am I being simplistic in my cursory look?

Thanks again!

February 14, 2008 7:06 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Christian: Unfortunately, the Keywords report will only show you the bid terms for your paid search. Basically, it will show you the keyword phrase that you bid upon, but not the one that visitors actually typed into the search engine. Hope that makes sense.

February 15, 2008 9:32 AM

Dave Cardwell said:

Thanks for updating this script and sharing it with the community.

I'm curious - why the "UA-1" in this line of the script:
_gat._getTracker("UA-1");

February 15, 2008 11:51 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Dave: It's just a precaution, due to the way that setVar operates, and we've found that it leads to more accurate usage stats.

February 15, 2008 1:57 PM

Searchquant said:

Doesn't it seem strange that Google wouldn't make this a feature in G Analytics early on? It's clear any smart marketer's gonna want to know which queries within phrase or broad matched keywords are working and not working.

Google gets 70% of its revenue from phrase and broad match.

February 15, 2008 4:53 PM

Sonja Bakker said:

Hi,

This quiet cool. I already saw that the previous script wasn't working anymore. Going to try this one now!

February 18, 2008 11:27 AM

Julien Raby said:

Hi Michael,

thanks a lot for this new version of the script, I was using the old filter hacks but it doesn't work anymore...

One question: the script as it is now doesn't seem to work if I manually tag my link (I almost always tag my links instead of using the auto-tagging to gain more control over the utm_campaign variable...) so I was wondering if there were a quick fix fo manual link tagger like myself?

Thanks again,
Julien

February 19, 2008 6:54 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Julien: While we definitely don't recommend that you manually tag AdWords ads (it causes problems when Analytics links up the data between your two accounts), this method should work for manually tagged links, so long as those links are tagged with utm_medium=cpc and the visits are coming from a search engine with a plainly visible search query in the URL (e.g., q=search+query, p=search+query, query=search+query).

February 22, 2008 3:28 PM

Chris Bradley said:

Thanks for this, I just tried the other method last week and didn't get it to work so this comes at a great time for me but I do have one question..

Should I upload the script to my root directory?

February 24, 2008 2:41 PM

Shawn Purtell, Senior Web Analytics Engineer Author Profile Page said:

@Chris:

You can upload the file wherever you like. Most websites have a specific place where scripts are stored, but it's different for everybody. The important thing is to make sure the call to the .js script is pointing to the right place.

February 25, 2008 9:29 AM

Charles Meaden said:

The actual ga_keyword2.js script contains the following lines


var pageTracker = _gat._getTracker("UA-XXXXXX-X");

The page says not to edit the script, but should I be changing the [yoursitehere] and UA-XXXX lines so that they correspond to our tracking codes?

March 17, 2008 10:40 AM

Jeremy Aube, Director of Engineering Author Profile Page said:

@Charles: Those lines are just a re-iteration of the installation instructions as given in the article. They are just comments, so you don't need to change it.

March 18, 2008 10:48 AM

Charles Meaden said:

Jeremy,

Thank you. Two more questions if I may.

1. Does it make any difference if I have amended the code to use our details
2. Can I use remove the commented section from the ga_keyword2.js file then

March 19, 2008 6:55 AM

Jeremy Aube, Director of Engineering Author Profile Page said:

@Charles: You really shouldn't be making any changes to the javascript file. If you're just making changes to or removing the comment section, that won't affect the functionality of the script, but it would be best to leave it as is. Then anyone who looks at the script will have the version number, author, general instructions (rather than specific to a single site's setup), and when it was last modified. Any changes to the script itself could negatively affect its functionality. Michael has written this script very precisely so that it needs no modification to work with your site.

March 19, 2008 9:52 AM

Ron said:

ok, I really want to get this data from my analytics and I have upgraded to ga and installed the tracking code...but I can't for the life of me understand where I find the detailed keyword search data in my analytics account. Can someone point me in the right direction?

April 2, 2008 4:21 PM

Jeremy Aube, Director of Engineering Author Profile Page said:

@Ron: The Exact Keyword Data for the site will be in the User Defined Report. You can also segment various reports by the User Defined Variable to see this information for specific visitor traffic segments. See Michael's previous post for more information.

April 2, 2008 4:39 PM

Ron said:

So if I look in the tab "Visitor/UserDefined" and all I see under the user defined values is "not set" then it's safe to assume I screwed up in inserting the tracking code?

April 2, 2008 5:35 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Ron: Well, it either means that you screwed up, or that you don't have any paid search traffic coming into your site. The traffic has to be auto-tagged AdWords clicks or manually tagged clicks with utm_medium=cpc.

Good luck!

April 3, 2008 10:59 AM

Ryan said:

Okay, I feel like an idiot.

The code checks out fine. Analytics is otherwise tracking fine. And I am getting my adwords PPC traffic to come up.

But STILL, I'm only getting "not set".

Is there something I'm missing? Maybe something obscenely obvious?

Thanks so much!

June 3, 2008 10:06 AM

Ryan said:

Yup. I'm definitely an idiot.

1. Didn't change the .js src path.

2. Didn't upload the .js file.

June 3, 2008 10:34 AM

Eric said:

Thanks for making these scripts. I put them on my site about a week ago, and the info has been very valuable.

Unfortunately, about 50% of the data comes back as (not set) and a slightly better return of only 33% on Yahoo. I don't have my account autotagged for various reasons, but every keyword has it's own URL with utm_medium=cpc. Is this the normal capture for the script or perhaps I have done something wrong or does the order of the utm_ variables in the search string matter. Currently I set the source, medium, campaign and then the term.

Thanks again for this wonderful tool.

June 10, 2008 2:36 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Eric: Well, content network will never display a search query, and some of the search partner sites don't format the search query in the same way that Google does. 50% is about the norm for what I see.

If you can find the search network sites that your ads are running and provide them, I may be able to expand the script to use their search queries.

June 10, 2008 4:27 PM

Daniel Waisberg said:

Hi Michael,

Thank you very much for the feature it is wonderful.

I was wondering if this code can work together with the one created by John Henson from LunaMetrics: Stuff More Than One Value into GA\x92s User Defined Segment . If so, this would solve the issue of using other User Defined Variables together with it.

Thank you again.

June 22, 2008 4:05 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Daniel: I don't see why the two scripts wouldn't play nice together. :) It may require some modifications to the JavaScript. Give it a shot and let us know how it works out.

June 24, 2008 8:24 AM

Eran Malloch said:

Hi Michael,

I REALLY REALLY REALLY need this tool to work (great idea and thanks to all who developed it), but unfortunately, whenever I add it to a site created by our webdesign partners, it somehow interferes with the script that creates their drop-down menu system, and the menu system stops working... :(

This has happened on 2 seperate sites now, and obviously we have to remove your script because a non-working menu system just aint gonna cut it. ;)

I'm guessing if this is happening to me, there are probably others it is happening to as well, but perhaps they haven't bothered to contact you and mention it.

ANY help you (or anyone else reading this comment) can provide with this issue would be GREATLY appreciated. I am happy to email you the offending site urls, etc.

Thanks in advance for your time, and I really do appreciate your efforts to provide this vital tool (and bah humbug to Google for NOT providing it) ;)


Eran Malloch
WCR Internet Marketing
Perth, Western Australia

July 11, 2008 2:22 AM

wil said:

How do I create a report that shows side-by-side the keyword in the AdWords campaign that was triggered along with the user defined variable (the search term). Right now, under traffic sources, I can see one or the other.

Thanks,

Wil

July 12, 2008 2:27 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Eran: I'd check to make sure that none of the functions from the menu system interfere with the keyword script. Beyond that, I don't see why it would cause any problems. Because of the sheer number of setups and JavaScript present on websites, there's no possible way we can troubleshoot each individual issue with the script, but if you have any additional comments on precisely what is going on (error messages, etc.), then maybe we can help out.

July 21, 2008 1:29 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Wil: There is no such report, but you could create a new profile with an Advanced Filter that plugs the User Defined field into the Campaign Term field. Just cram 'em both together, and that way when you look at your keywords list, you would see:

"bid term (search term)"

This will mean that cost and click data for your AdWords Campaigns keyword report will not match up properly, thus the reason why I recommend creating an additional profile.

Hope that helps.

July 21, 2008 1:36 PM

Eric Werner said:

Hi and thanks! One quick question, what does this do?

pageTracker._initData();

This line isn't in the code that Google gave me and you didn't mention anything about it in the post so I wanted to check.

Thanks!

August 8, 2008 12:18 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Eric: pageTracker._initData() is a deprecated function that was previously required before running the Google Analytics pageTracker. You can get rid of it or keep it in; entirely up to you.

August 8, 2008 1:52 PM

Jason said:

Michael - I've modified a function in the ga_keyword2.js code that I find quite useful re: more accurate stats gathering:

function noPercent(x)
{
x = unescape(x);
x = x.replace(/\+/g," ").replace(/^\s\s*/, '').replace(/\s\s*$/, '');
return x.toLowerCase(); // added feature
}


this basically groups all upper & lower case variations so that I get an accurate picture of the number of people using a particular word or phrase. Great script!

August 14, 2008 9:44 PM

Ricky said:

I think that this script looks great, and I have just updated the script on our site to check it out.

Though one question still remains, how does this differ from the report you get out of Adwords that shows you which search results that triggered your adwords to show and generate a click?

Thanks!

August 19, 2008 8:14 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Ricky: Check out my co-worker Mark Curtis' article on the Keyword Sleuth script versus the AdWords Search Query Performance Report for the answer to your question.

August 19, 2008 10:17 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Jason: Thanks for the info. You could also use a lowercase filter inside of Google Analytics if you don't want to modify the code (if, for instance, it's already installed on your site).

August 19, 2008 10:19 AM

Eric S said:

Michael, thanks again for this wonderful script. I recently upgraded to the new tracking code and the script worked fine. Unfortunately, my 'check-out' is handled by a third party that is still running the legacy script and they are hesitant to upgrade. Note that their legacy script also has

_udn="none";
_ulink=1;

in the legacy code to enable cross-domain tracking.

So, I downgraded back to the legacy code and added the two lines for cross-domain tracking code that I had not used before, and the next day all of my User Defined Value data was missing. So I deleted the

_udn="none";
_ulink=1;

lines and it immediately returned but this left me without the cross domain tracking I had hoped to gain. Note that the User Defined Value came through just fine in the ga.js version except the link was broken across the domains due to code incompatability. Any suggestions for getting the legacy version to work cross-domain. I noticed that the slueth(); function was in the legacy code on your first blog in 07 but not the more recent blog. Might this be part of it?

On a completely separate issue, I appended the cpc search term that actually responded to the original user query to the UDV and was stunned at the level of mismatch. For example, I had a phrase/exact match bid for "word1 word2 word3 word4", the user queried the exact term "word1 word2 word3 word4" but Google responded to the query with a broad matched term "word1 word2 wordX" where wordX was barely a synonym but the price point was much higher--not to mention the ad displayed to the user's query was far less relevant because the reponse came from a different ad group. Google does this a lot.

Do you see this mis-matching to increase Search Engine revenues a lot and does your consulting service offer methods of combating this problem of what seems a lot like fraud?

August 31, 2008 8:45 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Eric S: As long as you properly tag links between domains with utmLinker, you should be fine. It should bridge the gap between domains with the right cookie information.

Good luck!

September 2, 2008 3:24 PM

Mike said:

Hi Michael,

I am on the ROI GA Online training.

I have installed the Sleuth Tracking code, but I get "(not set)" when I go check the User Defined data.

I cannot spot what I am doing wrong.

You can view my code in the source of this page:

http://www.enquete-satisfaction.com/

Thanks for your help!
Mike

October 6, 2008 9:06 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Mike: The ga_keyword2.js file must go between the first <script> section of the Google Analytics Tracking Code and the second. You have it before. Please read the article again and be sure to place it in precisely the spot that I indicated. That should fix it for you.

You also should be wary of "smart" or curled quotes showing up in your code. If you use Microsoft Outlook or Word to edit code with quotation marks and paste it into your site, you might end up with a left or a right curled quote (“ or ”) instead of a standard quote ("). Be sure to only use standard quote marks in HTML code.

October 6, 2008 11:03 AM

Mike said:

Michael,

Could it be that I had copied the code from an older version of the article?

I am asking since my code also includes Sleuth() at the end, that the new code doesn't seem to include.

Thanks for your help!
Mike

October 8, 2008 9:52 AM

Eddy said:

This is a great script that I have been using flawlessly for a while now, but for the past month or so, all the keywords within the user defined page are still attached to the Google search query that is after the q variable as in http://www.google.co.uk/search?hl=en&q=keyword1+keyword2&meta=
I dont understand why this has started happening but could do with some advice.

thanks
eddy

October 8, 2008 11:43 AM

Eddy said:

Michael, if not done so already is it possible to add the search queries for the following Google search network partners?
aolsearch.aol.co.uk
www.winbuyer.co.uk
search.babylon.com
www.kellysearch.co.uk
business.shop.ebay.co.uk
search.virginmedia.com
www.hotfroguk.co.uk
uk.ask.com
www.tiscali.co.uk
search1.sky.com
search.mywebsearch.com

there are quite a few more but they generate just one or two visits.

regards
eddy

October 8, 2008 12:35 PM

art said:

Great script. Cant wait to see the results.

October 12, 2008 10:35 PM

Mike said:

Hi Michael,

I got the script to work. However, there are 2 issues:

1) About 20-25% of the visits show as "not set" (I don't use content for that campaign, only search with Google & Search Network).

Can you tell what they could account for?

2) It's a campaign with French keywords and the script doesn't capture the accents properly (whereas GA's Traffic Sources > Keyword Report does). E.g. the word "pr\xE9vention" shows as "prévention".

Is there a way to correct that?

Thanks!
Mike

October 13, 2008 8:04 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Mike: The reason why 20-25% of your visits are "not set" is because the script currently does not account for all of the engines that are a part of the Google search network. We've been working on an update for that, which should be released in the next few days, and should reduce the percentage of "not sets".

We'll also work on getting the accents fixed. Thanks for letting me know!

October 14, 2008 10:42 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Eddy: I'm not really sure what you mean by this. Can you illustrate with a screenshot or a URL?

October 14, 2008 10:45 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Eddy: I've been working on the script, trying to increase the number of search engine query parameters that it recognizes. Thanks for your list, and look for an update over the next few days.

October 14, 2008 10:46 AM

art said:

Great tool! I have started to see the results and they are amazing. 80% of my visits are showing as "not set". Are they all as a results of google parters not being included or because I haven't set utm_medium=ppc for both yahoo and msn ppc traffic? the interesting part is the bulk of our revenue is coming from google partners/or the other engines...the "not set" portion.

Second question..I want to add another domain which is an add-on to the main domain..Do I follow the exact steps for additional domains.

October 15, 2008 12:42 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Art: It could be because you haven't set utm_medium=cpc for Yahoo! and MSN paid traffic. Many Google partners aren't included yet, either, but I'll be posting an update to the script that will contain more of those partners. Keep an eye out on the blog, or subscribe to it to keep up-to-date.

October 15, 2008 10:26 AM

Clikckbank Affiliates said:

Thanks for the update...

October 20, 2008 3:14 PM

Moses Chang said:

Hi, just stumbled upon this tool and immediately created a new Google Analytics account for our website and installed it. Do I lose the ability to track AdWords Campaigns (under the Traffic Sources tab in Google Analytics) once this tool is installed? I also can't find where the search query info are being displayed...

Thanks in advance,
Moses

October 22, 2008 10:46 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Moses: This won't affect your AdWords Campaigns report and won't take away your ability to track campaigns, adgroups, or keywords. To access the exact keyword information, you can either drill down to a specific campaign/adgroup/keyword in the Traffic Sources > AdWords > AdWords Campaigns report and use the Dimension User Defined dropdown.

You can also view all of your exact keyword combinations using the Visitors > User Defined report.

October 22, 2008 11:01 AM

Aidin said:

How does this differ from the filter hack? Which one is better?

November 4, 2008 6:04 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Aidin: Check out my first article when I first created the script for how it differs from Omega's filter hack. I like the script better for the reasons outlined there.

November 5, 2008 1:32 PM

Gavin Doolan said:

Hi there,
I wonder if its possible to concatenate search queries to the user defined value to see data before the last click. (preventing a last click wins scenario)

What I mean is see the string of keywords used before a purchase. Say during the buyer research phase, till the point of purchase?

Obviously there is also the issue of previous campaigns which triggered a visit such as banner / email but I figured this may be the place to mention such an idea.

I've only just started to learn JS myself, perhaps by the time I'm finished reading my current book I'll have an idea on how to do it myself.

Cheers,
Gavin.

November 12, 2008 5:00 AM

Mike said:

Hello Michael,

Are you aware of this Advanced Filter setup that shows the bid keyword + exact search query?

http://www.ga-experts.com/blog/2006/11/how-to-get-detailed-ppc-keyword-data-from-google-analytics/

If so can you comment on the advantages/disadvantages of yours vs. theirs?

One thing that comes to mind is that theirs leaves the User Defined variable free for another utilization.

Thanks!
Mike

November 18, 2008 4:05 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Gavin: It's definitely possible. We've been working on something very similar here. Good luck on your own JS pursuits! Let us know if you post something about this elsewhere and we'll be sure to give you some link love.

November 19, 2008 3:11 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Mike: Definitely. It was Brian's filter that inspired me. The only issue I had with their is how it works on return visits to sites. See my original article for a full explanation.

November 19, 2008 3:13 PM

Aidin said:

Is there a way to implement this script to another profile?The first profile is already using the user defined field by live person chat. Could the two coexist within the same profile?

November 26, 2008 4:03 PM

Bud Gibson said:

How does this play with something like advanced segmentation? I was looking at those reports, and they seem to show what percentage of your search traffic for a given keyword is from paid sources.

The one thing I can see is that I might be able to see how my keywords are broad matching to actual search terms.

December 9, 2008 8:36 AM

Amit said:

Hi Michael,

Awesome post!
I was wondering if combining all the javascript in to a single .js file would be ok?

ON THE WEBPAGE YOUR WOULD PUT:

THE CONTENTS ON MyGA.js WOULD LOOK AS FOLLOWS:

var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));

function noPercent(x)
{
x = unescape(x);
return x.replace(/\+/g," ").replace(/^\s\s*/, '').replace(/\s\s*$/, '');
}

function getRef()
{
ref = document.referrer;
re = /(\?|&)(q|p|query|encquery|qt|terms|rdata|qs|wd|text|szukaj|k|searchExpr|
search_for|string|search_query|searchfor)=([^&]+)/;
searchq = re.exec(ref);
if(searchq) {
searchq[3] = noPercent(searchq[3]);
sleuthTracker._setVar(searchq[3]);
}
else {
sleuthTracker._setVar('Referral: ' + document.referrer);
}
}

function sleuth()
{
if(document.location.search.indexOf("gclid")!=-1||
document.location.search.indexOf("cpc")!=-1) {
getRef();
}
}

var sleuthTracker = _gat._getTracker("UA-1");
sleuthTracker._initData();
sleuth();

var pageTracker = _gat._getTracker("UA-XXXXXX-1");
pageTracker._initData();
pageTracker._trackPageview();

December 24, 2008 4:45 AM

Amit said:

no worries, I figured out why they need to be seperate. Thanks!

December 24, 2008 5:16 AM

rookie said:

The script works great!!
Can somebody help me to modify the script to append the ip of the user next to the search string? This would be invaluable for our statistical analysis. Unfortunately my javascript knowledge is limited. Thanks in advance!

January 4, 2009 6:22 PM

Bud Gibson said:

I just installed this script. An observation: why didn't you name space it? That would eliminate almost all possibilities of javascript conflict which I noticed one commenter remarking. I may do that myself if I get some spare time. It just involves encapsulating your functions in an object with a particular name. You then access the functions with Object.functionName().

January 7, 2009 10:37 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Amit: Yep, there's a reason why they're separate, though you can wrangle the JavaScript in such a way that there's only a single reference for all Google Analytics code, if you wanted to.

January 29, 2009 1:37 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@rookie: Glad the script is working for you!

As pulling IP addresses into Google Analytics actually violates the terms and conditions (and is impossible to do with JavaScript alone), there are currently no plans to add this functionality to the script.

January 29, 2009 1:43 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Bud: We have been testing a version of this script internally that expands on the features and uses object-oriented coding, but you're welcome to post your own.

January 29, 2009 1:50 PM

satin jain said:

but where i put this code..

i m new about this stuff...

please tell me where i have two put this script ...

please tell me...

February 13, 2009 2:55 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@satin jain: Just replace the exiting Google Analytics code, wherever it is on the page, with the one in the box.

February 13, 2009 3:17 PM

Brian Kaldenberg said:

I have installed everything and it appears to be tracking exact keywords correctly.

Problem is when inside analytics if I click the "clicks" tab, none of the clicks, impressions, ctr, cost, etc. data is showing up for dimension user-defined.

I have auto-link tag set to on.

Clicks data shows up for my broad match adgroup, but isn't the point of exact keyword tracking to be able to see clicks data for exact keywords within broad match?

I sure hope it is possible.

February 27, 2009 1:58 AM

Nikki said:

Hi

Is there a way of relating the keyword input to the keyword bid on? e.g. a hybrid of yours and Brian Cliftons PPC terms methods (his override bid term filter). So that a client can see e.g. car parking (car+parking+greater+manchester) using the ga2.js file?

Thanks
Nikki

March 16, 2009 8:54 AM

Richie Rich said:

Hi Michael. I have been successfully using the code here on 6 PPC accounts and the information has proved invaluable - thx so much for this.
However today on 2 of my 6 accounts I have no adwords data showing in my analytics? (and therefor no excat keyword tracking. Have you experienced this before - it may very well be an adwords glitch? Any ideas?

March 25, 2009 8:26 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Richie: No idea why it's not working. Have you checked to make sure that your AdWords linking and cost data is all set up properly?

March 25, 2009 3:20 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Nikki: It seems like it would be possible using filters. Give it a go and let us know how it works out.

March 25, 2009 3:24 PM

Medela Dude said:

Hi Mike, appreciate your work on this and have been using it for a year or 2 now.

Any news on a resolution to the "Not Set" issue?

May 6, 2009 10:51 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Medela Dude: Not yet. There's just a lot of traffic from Google that doesn't match the standard query. We'll definitely keep everyone posted with any updates to the code. Be sure to add the ROI blog to your reader of choice or subscribe via email with the link at the top right.

May 6, 2009 2:27 PM

Salman said:

I have implemented the script. Works fine. It returns the actual KWs in the user defined reports, however there is no goal conversions associated with these KWs although i know that i have made conversions through these KWs.

May 15, 2009 12:17 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Salman: Try drilling down to the keyword level in the Keywords report where you should see your conversions. Then segment by User Defined. What do you see?

May 15, 2009 9:57 AM

Neal said:

Michael, does this keyword filter affect GA ecommerce data? I recently installed it in one of my sites...I see the specific queries from Adwords but don't see conversion data. Our overall ecommerce stats also show $0 revenue right after installing the GA code.

June 19, 2009 7:39 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Neal: It shouldn't affect ecommerce data. What happens when you remove it?

June 22, 2009 11:53 AM

Neal said:

Michael,

We installed the code and all ecommerce data stopped reporting. We were averaging several $30,000 in revenue per day and then it went to $0 after we changed the GA code. Any ideas?

June 24, 2009 9:57 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Neal: Have you tried using the Exact Keyword Tracking script on all pages but your receipt page?

June 25, 2009 4:58 PM

Vince said:

Can someone explain how we can embed this data into our Website forms so the search keywords and PPC data is added to our leads please?

Basically, trying to achieve the same as what Salesforce.com Google adwords integration has with their web-to-lead form.
http://www.semgeek.com/semgeek/2008/03/what-you-need-t.html

July 18, 2009 9:49 AM

neal@akamaiseo.com said:


Michael, are you saying that the modified GA script needs to be on every page of your site except for your confirmation/receipt page?

July 20, 2009 3:51 PM

afzal hanif said:

Really great post, thanx. Right now i'm using the alternate 'filter method' to show the true keywords, however, conversions are still only attributed to the original (adwords) keyword. Perhaps I overlooked, but will this javascript method also show conversions to the true keywords? Hope you can help me, thanx:)

August 6, 2009 3:55 AM

afzal hanif said:

Nice post. I have been using the alternate mode now for a while, but one issue with this: conversions are not attributed to the 'true keywords', but to the keyword defined in adwords. Will this method show actual conversions to the true keywords? Perhaps I missed it but thanx in advance:)!

August 11, 2009 10:44 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Afzal: Yes, it will. One benefit it has over the other method. Just be sure to use the user defined report.

August 19, 2009 10:22 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Neal: Technically it should be on every possible landing page. You can write conditional JavaScript to check and see whether or not this is this case, or you can just put it on every page. Either way works, really.

August 19, 2009 10:32 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Vince: That's a bit more complicated. Justin Cutroni has detailed a method for something similar at his blog. Hope it helps!

August 19, 2009 10:36 AM

Jen said:

thanks Michael and ROIRev. This one gave us substantial savings over a twelve month period.

September 4, 2009 4:51 AM

Guy said:

Great stuff!!
Any way to fix it to show utf-8 keywords?

October 9, 2009 11:26 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Guy: To be honest, I haven't spent a lot of time working on the script. If you'd like to add decoding for utf-8, please feel free! Just let us know of any updates so we can share the wealth.

October 9, 2009 1:24 PM

Riedel Wine Glass said:

So should this script be on every page in the website? sorry newbie question

December 22, 2009 3:18 PM

Wytze said:

Thanks a million Michael,

Your script has made our year! Like somebody else mentioned earlier. This information is invaluable! Only running for a couple of days and I've already seen so many incorrect queries!

I do have a question though, is there a way to associate costs to the queries like you see with Search Query reports in Adwords?

Thanks again so much and have an early merry christmas! :)

December 23, 2009 7:00 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Riedel: Yes, put it on every page of your site. It should replace the standard Google Analytics Tracking Code.

January 4, 2010 5:55 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Wytze: No, there's not currently a way to associate costs with the queries. We typically just use the SQR in AdWords to do that.

January 4, 2010 5:57 PM

David Ogletree said:

I used to work at a ppc agency and our Google rep gave me a filter that let me track search partners. I did not save the filter and I don't have access to that account anymore. I can't seem to find how to do this again. Can you make a filter that does this?

January 12, 2010 9:46 AM

GregBB said:

What would be the reasons to favor the ga.js update to view actual search phrases in comparison to applying the "Override Bid Term" filters? Is the result the same? One obvious reason is that you can instantly apply it to all profiles, which could also be a disincentive if you would like to have more flexibility. Would appreciate your thoughts. Thanks!

February 4, 2010 8:01 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@David: You can add a query parameter to your destination URLs and then use the special AdWords macro {placement} to insert the URL that the ad was displayed on, like so:

www.mysite.com?site={placement}

Then you can use something like Filters, Site Search or Custom Variables to pull that data out and put it into a Google Analytics report.

March 6, 2010 4:18 PM

Kevin Joyner said:

Hi Michael

I seem to have gathered the impression from somewhere that there are plans ultimately to deprecate the GA user defined variable, and that we should use custom variables where possible.

Would it be worthwhile to adapt your Keyword Sleuth script to use custom variables? If so, I don't suppose you've done that, have you? :-)

Many thanks

Kevin

April 20, 2010 9:00 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Kevin: We have, and it works just fine. Look for an article about it in the near future.

April 20, 2010 11:10 AM

Sandra said:

Ok...pardon the moron. I have read this entire thread and just want to make sure I understand completely b4 I implement the code.

1. I literally just REPLACE the code on my sites with the one up top u provide (obviously changing the profile numbers)?

2. Do I have to also upload this ga_keyword2.js file? If so, why?

Thanks so much - really looking 4ward to taking it for a test drive!

S

May 19, 2010 3:55 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Sandra: Yes, replace the code on your site with the one above. And, yes, you do need to upload the file. Why? Because that's where all the code that grabs the search query is.

May 25, 2010 9:42 AM

Eric said:

Hi Michael,

I wanted to thank you for this wonderful tool. We've been using it for almost 2 years and its benefit has been significant.

Yesterday, I upgraded my site to the new asynchronous GATC code but wasn't quite sure how to integrate ga_keyword.js so I took my best shot as shown below. No luck--the user defined value data has disappeared.

Actually, there are two problems here. Whenever I originally set up the 'traditional' GATC code with the two additional lines for cross-domain tracking, the UDV info would disappeared. We decided knowing what the original queries were outweighed cross domain tracking so we just left out the

pageTracker._setDomainName('none');
pageTracker._setAllowLinker(true);

lines and lived with the compromise. This time I included the asynchronous equivalent for cross domain hoping it would work but no luck.

_gaq.push(['_setDomainName', 'none']);
_gaq.push(['_setAllowLinker', true]);

So I've changed too many variables to know what the real problem is, but if this is a no-brainer for you, would you please point out my error. Alternately, I can go back and remove the cross domain asynchronous lines to try and isolate the cause and effect and see what happens.

Also noticed an early post about deprecating the _setVar() function and an upcoming post about that? Perhaps that post might be nearby?

Would be grateful for any help.

Eric.

Current Attempt:

<!--
<head>

<script src="ga_keyword.js" type="text/javascript"></script>

<script type="text/javascript">

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-123456-1']);

_gaq.push(['_setDomainName', 'none']);
_gaq.push(['_setAllowLinker', true]);

_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

</script>

</head>
-->

July 7, 2010 9:00 AM

Darrell said:

Google Adwords lets me generate a report of keyphrases typed that caused ads to show up and wheter they generated clicks or not. These are phrases typed during the search, including searches on other sites, not just the keyword that match the ad. I can then see phrases generating clicks that I don't like the words that are in them, then ad those to my negative keywords. Is this something new that was not available in 2008 when this ga_keyword script was created?

September 8, 2010 5:52 PM

George Strait Tickets said:

Then you can use something like Filters, Site Search or Custom Variables to pull that data out and put it into a Google Analytics report.

September 23, 2010 5:58 AM

Christina said:

I used to work at a ppc agency and our Google rep gave me a filter that let me track search partners. I did not save the filter and I don't have access to that account anymore. I can't seem to find how to do this again. Can you make a filter that does this

October 26, 2010 8:58 AM

PPC Whiz said:

This stuff is great! Keep up the good work team, I really appreciate you sharing this with the community. You are an excellent resource for us PPC guys out there looking to maximize our spend.
My clients will thank you!

February 14, 2008 3:25 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@PPC Whiz: Glad we could help out! Definitely keep posted here on any additions or updates, and like I said in my post, our own team will be posting some of their tips and tricks in the coming weeks.

February 14, 2008 4:22 PM

Jesse DaCosta said:

Hey Michael,

Thanks for the update, have been on the lookout for it! I've tried another method from another blog but that doesn't seem to work, at least for me, so now I've updated to the new code I'm going to test this out.

Thanks again!

February 14, 2008 4:37 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Jesse: Great! Let me know how it works for you. We're always trying to improve it.

February 14, 2008 5:54 PM

Christian Martin said:

Thanks for updating the ga.js script with this! I only saw the original change for the old urchin code yesterday after your webinar. I've already changed the GA code on both our site and looking forward to seeing the results in the coming days.

I do have a question... In the Traffic Sources::Keywords section, their are toggles for Show: total | paid | non-paid and then the Segment listbox.

On first glance, it would seem GA is providing everything without the script. Am I being simplistic in my cursory look?

Thanks again!

February 14, 2008 7:06 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Christian: Unfortunately, the Keywords report will only show you the bid terms for your paid search. Basically, it will show you the keyword phrase that you bid upon, but not the one that visitors actually typed into the search engine. Hope that makes sense.

February 15, 2008 9:32 AM

Dave Cardwell said:

Thanks for updating this script and sharing it with the community.

I'm curious - why the "UA-1" in this line of the script:
_gat._getTracker("UA-1");

February 15, 2008 11:51 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Dave: It's just a precaution, due to the way that setVar operates, and we've found that it leads to more accurate usage stats.

February 15, 2008 1:57 PM

Searchquant said:

Doesn't it seem strange that Google wouldn't make this a feature in G Analytics early on? It's clear any smart marketer's gonna want to know which queries within phrase or broad matched keywords are working and not working.

Google gets 70% of its revenue from phrase and broad match.

February 15, 2008 4:53 PM

Sonja Bakker said:

Hi,

This quiet cool. I already saw that the previous script wasn't working anymore. Going to try this one now!

February 18, 2008 11:27 AM

Julien Raby said:

Hi Michael,

thanks a lot for this new version of the script, I was using the old filter hacks but it doesn't work anymore...

One question: the script as it is now doesn't seem to work if I manually tag my link (I almost always tag my links instead of using the auto-tagging to gain more control over the utm_campaign variable...) so I was wondering if there were a quick fix fo manual link tagger like myself?

Thanks again,
Julien

February 19, 2008 6:54 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Julien: While we definitely don't recommend that you manually tag AdWords ads (it causes problems when Analytics links up the data between your two accounts), this method should work for manually tagged links, so long as those links are tagged with utm_medium=cpc and the visits are coming from a search engine with a plainly visible search query in the URL (e.g., q=search+query, p=search+query, query=search+query).

February 22, 2008 3:28 PM

Chris Bradley said:

Thanks for this, I just tried the other method last week and didn't get it to work so this comes at a great time for me but I do have one question..

Should I upload the script to my root directory?

February 24, 2008 2:41 PM

Shawn Purtell, Senior Web Analytics Engineer Author Profile Page said:

@Chris:

You can upload the file wherever you like. Most websites have a specific place where scripts are stored, but it's different for everybody. The important thing is to make sure the call to the .js script is pointing to the right place.

February 25, 2008 9:29 AM

Charles Meaden said:

The actual ga_keyword2.js script contains the following lines


var pageTracker = _gat._getTracker("UA-XXXXXX-X");

The page says not to edit the script, but should I be changing the [yoursitehere] and UA-XXXX lines so that they correspond to our tracking codes?

March 17, 2008 10:40 AM

Jeremy Aube, Director of Engineering Author Profile Page said:

@Charles: Those lines are just a re-iteration of the installation instructions as given in the article. They are just comments, so you don't need to change it.

March 18, 2008 10:48 AM

Charles Meaden said:

Jeremy,

Thank you. Two more questions if I may.

1. Does it make any difference if I have amended the code to use our details
2. Can I use remove the commented section from the ga_keyword2.js file then

March 19, 2008 6:55 AM

Jeremy Aube, Director of Engineering Author Profile Page said:

@Charles: You really shouldn't be making any changes to the javascript file. If you're just making changes to or removing the comment section, that won't affect the functionality of the script, but it would be best to leave it as is. Then anyone who looks at the script will have the version number, author, general instructions (rather than specific to a single site's setup), and when it was last modified. Any changes to the script itself could negatively affect its functionality. Michael has written this script very precisely so that it needs no modification to work with your site.

March 19, 2008 9:52 AM

Ron said:

ok, I really want to get this data from my analytics and I have upgraded to ga and installed the tracking code...but I can't for the life of me understand where I find the detailed keyword search data in my analytics account. Can someone point me in the right direction?

April 2, 2008 4:21 PM

Jeremy Aube, Director of Engineering Author Profile Page said:

@Ron: The Exact Keyword Data for the site will be in the User Defined Report. You can also segment various reports by the User Defined Variable to see this information for specific visitor traffic segments. See Michael's previous post for more information.

April 2, 2008 4:39 PM

Ron said:

So if I look in the tab "Visitor/UserDefined" and all I see under the user defined values is "not set" then it's safe to assume I screwed up in inserting the tracking code?

April 2, 2008 5:35 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Ron: Well, it either means that you screwed up, or that you don't have any paid search traffic coming into your site. The traffic has to be auto-tagged AdWords clicks or manually tagged clicks with utm_medium=cpc.

Good luck!

April 3, 2008 10:59 AM

Ryan said:

Okay, I feel like an idiot.

The code checks out fine. Analytics is otherwise tracking fine. And I am getting my adwords PPC traffic to come up.

But STILL, I'm only getting "not set".

Is there something I'm missing? Maybe something obscenely obvious?

Thanks so much!

June 3, 2008 10:06 AM

Ryan said:

Yup. I'm definitely an idiot.

1. Didn't change the .js src path.

2. Didn't upload the .js file.

June 3, 2008 10:34 AM

Eric said:

Thanks for making these scripts. I put them on my site about a week ago, and the info has been very valuable.

Unfortunately, about 50% of the data comes back as (not set) and a slightly better return of only 33% on Yahoo. I don't have my account autotagged for various reasons, but every keyword has it's own URL with utm_medium=cpc. Is this the normal capture for the script or perhaps I have done something wrong or does the order of the utm_ variables in the search string matter. Currently I set the source, medium, campaign and then the term.

Thanks again for this wonderful tool.

June 10, 2008 2:36 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Eric: Well, content network will never display a search query, and some of the search partner sites don't format the search query in the same way that Google does. 50% is about the norm for what I see.

If you can find the search network sites that your ads are running and provide them, I may be able to expand the script to use their search queries.

June 10, 2008 4:27 PM

Daniel Waisberg said:

Hi Michael,

Thank you very much for the feature it is wonderful.

I was wondering if this code can work together with the one created by John Henson from LunaMetrics: Stuff More Than One Value into GA\x92s User Defined Segment . If so, this would solve the issue of using other User Defined Variables together with it.

Thank you again.

June 22, 2008 4:05 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Daniel: I don't see why the two scripts wouldn't play nice together. :) It may require some modifications to the JavaScript. Give it a shot and let us know how it works out.

June 24, 2008 8:24 AM

Eran Malloch said:

Hi Michael,

I REALLY REALLY REALLY need this tool to work (great idea and thanks to all who developed it), but unfortunately, whenever I add it to a site created by our webdesign partners, it somehow interferes with the script that creates their drop-down menu system, and the menu system stops working... :(

This has happened on 2 seperate sites now, and obviously we have to remove your script because a non-working menu system just aint gonna cut it. ;)

I'm guessing if this is happening to me, there are probably others it is happening to as well, but perhaps they haven't bothered to contact you and mention it.

ANY help you (or anyone else reading this comment) can provide with this issue would be GREATLY appreciated. I am happy to email you the offending site urls, etc.

Thanks in advance for your time, and I really do appreciate your efforts to provide this vital tool (and bah humbug to Google for NOT providing it) ;)


Eran Malloch
WCR Internet Marketing
Perth, Western Australia

July 11, 2008 2:22 AM

wil said:

How do I create a report that shows side-by-side the keyword in the AdWords campaign that was triggered along with the user defined variable (the search term). Right now, under traffic sources, I can see one or the other.

Thanks,

Wil

July 12, 2008 2:27 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Eran: I'd check to make sure that none of the functions from the menu system interfere with the keyword script. Beyond that, I don't see why it would cause any problems. Because of the sheer number of setups and JavaScript present on websites, there's no possible way we can troubleshoot each individual issue with the script, but if you have any additional comments on precisely what is going on (error messages, etc.), then maybe we can help out.

July 21, 2008 1:29 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Wil: There is no such report, but you could create a new profile with an Advanced Filter that plugs the User Defined field into the Campaign Term field. Just cram 'em both together, and that way when you look at your keywords list, you would see:

"bid term (search term)"

This will mean that cost and click data for your AdWords Campaigns keyword report will not match up properly, thus the reason why I recommend creating an additional profile.

Hope that helps.

July 21, 2008 1:36 PM

Eric Werner said:

Hi and thanks! One quick question, what does this do?

pageTracker._initData();

This line isn't in the code that Google gave me and you didn't mention anything about it in the post so I wanted to check.

Thanks!

August 8, 2008 12:18 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Eric: pageTracker._initData() is a deprecated function that was previously required before running the Google Analytics pageTracker. You can get rid of it or keep it in; entirely up to you.

August 8, 2008 1:52 PM

Jason said:

Michael - I've modified a function in the ga_keyword2.js code that I find quite useful re: more accurate stats gathering:

function noPercent(x)
{
x = unescape(x);
x = x.replace(/\+/g," ").replace(/^\s\s*/, '').replace(/\s\s*$/, '');
return x.toLowerCase(); // added feature
}


this basically groups all upper & lower case variations so that I get an accurate picture of the number of people using a particular word or phrase. Great script!

August 14, 2008 9:44 PM

Ricky said:

I think that this script looks great, and I have just updated the script on our site to check it out.

Though one question still remains, how does this differ from the report you get out of Adwords that shows you which search results that triggered your adwords to show and generate a click?

Thanks!

August 19, 2008 8:14 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Ricky: Check out my co-worker Mark Curtis' article on the Keyword Sleuth script versus the AdWords Search Query Performance Report for the answer to your question.

August 19, 2008 10:17 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Jason: Thanks for the info. You could also use a lowercase filter inside of Google Analytics if you don't want to modify the code (if, for instance, it's already installed on your site).

August 19, 2008 10:19 AM

Eric S said:

Michael, thanks again for this wonderful script. I recently upgraded to the new tracking code and the script worked fine. Unfortunately, my 'check-out' is handled by a third party that is still running the legacy script and they are hesitant to upgrade. Note that their legacy script also has

_udn="none";
_ulink=1;

in the legacy code to enable cross-domain tracking.

So, I downgraded back to the legacy code and added the two lines for cross-domain tracking code that I had not used before, and the next day all of my User Defined Value data was missing. So I deleted the

_udn="none";
_ulink=1;

lines and it immediately returned but this left me without the cross domain tracking I had hoped to gain. Note that the User Defined Value came through just fine in the ga.js version except the link was broken across the domains due to code incompatability. Any suggestions for getting the legacy version to work cross-domain. I noticed that the slueth(); function was in the legacy code on your first blog in 07 but not the more recent blog. Might this be part of it?

On a completely separate issue, I appended the cpc search term that actually responded to the original user query to the UDV and was stunned at the level of mismatch. For example, I had a phrase/exact match bid for "word1 word2 word3 word4", the user queried the exact term "word1 word2 word3 word4" but Google responded to the query with a broad matched term "word1 word2 wordX" where wordX was barely a synonym but the price point was much higher--not to mention the ad displayed to the user's query was far less relevant because the reponse came from a different ad group. Google does this a lot.

Do you see this mis-matching to increase Search Engine revenues a lot and does your consulting service offer methods of combating this problem of what seems a lot like fraud?

August 31, 2008 8:45 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Eric S: As long as you properly tag links between domains with utmLinker, you should be fine. It should bridge the gap between domains with the right cookie information.

Good luck!

September 2, 2008 3:24 PM

Mike said:

Hi Michael,

I am on the ROI GA Online training.

I have installed the Sleuth Tracking code, but I get "(not set)" when I go check the User Defined data.

I cannot spot what I am doing wrong.

You can view my code in the source of this page:

http://www.enquete-satisfaction.com/

Thanks for your help!
Mike

October 6, 2008 9:06 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Mike: The ga_keyword2.js file must go between the first <script> section of the Google Analytics Tracking Code and the second. You have it before. Please read the article again and be sure to place it in precisely the spot that I indicated. That should fix it for you.

You also should be wary of "smart" or curled quotes showing up in your code. If you use Microsoft Outlook or Word to edit code with quotation marks and paste it into your site, you might end up with a left or a right curled quote (“ or ”) instead of a standard quote ("). Be sure to only use standard quote marks in HTML code.

October 6, 2008 11:03 AM

Mike said:

Michael,

Could it be that I had copied the code from an older version of the article?

I am asking since my code also includes Sleuth() at the end, that the new code doesn't seem to include.

Thanks for your help!
Mike

October 8, 2008 9:52 AM

Eddy said:

This is a great script that I have been using flawlessly for a while now, but for the past month or so, all the keywords within the user defined page are still attached to the Google search query that is after the q variable as in http://www.google.co.uk/search?hl=en&q=keyword1+keyword2&meta=
I dont understand why this has started happening but could do with some advice.

thanks
eddy

October 8, 2008 11:43 AM

Eddy said:

Michael, if not done so already is it possible to add the search queries for the following Google search network partners?
aolsearch.aol.co.uk
www.winbuyer.co.uk
search.babylon.com
www.kellysearch.co.uk
business.shop.ebay.co.uk
search.virginmedia.com
www.hotfroguk.co.uk
uk.ask.com
www.tiscali.co.uk
search1.sky.com
search.mywebsearch.com

there are quite a few more but they generate just one or two visits.

regards
eddy

October 8, 2008 12:35 PM

art said:

Great script. Cant wait to see the results.

October 12, 2008 10:35 PM

Mike said:

Hi Michael,

I got the script to work. However, there are 2 issues:

1) About 20-25% of the visits show as "not set" (I don't use content for that campaign, only search with Google & Search Network).

Can you tell what they could account for?

2) It's a campaign with French keywords and the script doesn't capture the accents properly (whereas GA's Traffic Sources > Keyword Report does). E.g. the word "pr\xE9vention" shows as "prévention".

Is there a way to correct that?

Thanks!
Mike

October 13, 2008 8:04 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Mike: The reason why 20-25% of your visits are "not set" is because the script currently does not account for all of the engines that are a part of the Google search network. We've been working on an update for that, which should be released in the next few days, and should reduce the percentage of "not sets".

We'll also work on getting the accents fixed. Thanks for letting me know!

October 14, 2008 10:42 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Eddy: I'm not really sure what you mean by this. Can you illustrate with a screenshot or a URL?

October 14, 2008 10:45 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Eddy: I've been working on the script, trying to increase the number of search engine query parameters that it recognizes. Thanks for your list, and look for an update over the next few days.

October 14, 2008 10:46 AM

art said:

Great tool! I have started to see the results and they are amazing. 80% of my visits are showing as "not set". Are they all as a results of google parters not being included or because I haven't set utm_medium=ppc for both yahoo and msn ppc traffic? the interesting part is the bulk of our revenue is coming from google partners/or the other engines...the "not set" portion.

Second question..I want to add another domain which is an add-on to the main domain..Do I follow the exact steps for additional domains.

October 15, 2008 12:42 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Art: It could be because you haven't set utm_medium=cpc for Yahoo! and MSN paid traffic. Many Google partners aren't included yet, either, but I'll be posting an update to the script that will contain more of those partners. Keep an eye out on the blog, or subscribe to it to keep up-to-date.

October 15, 2008 10:26 AM

Clikckbank Affiliates said:

Thanks for the update...

October 20, 2008 3:14 PM

Moses Chang said:

Hi, just stumbled upon this tool and immediately created a new Google Analytics account for our website and installed it. Do I lose the ability to track AdWords Campaigns (under the Traffic Sources tab in Google Analytics) once this tool is installed? I also can't find where the search query info are being displayed...

Thanks in advance,
Moses

October 22, 2008 10:46 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Moses: This won't affect your AdWords Campaigns report and won't take away your ability to track campaigns, adgroups, or keywords. To access the exact keyword information, you can either drill down to a specific campaign/adgroup/keyword in the Traffic Sources > AdWords > AdWords Campaigns report and use the Dimension User Defined dropdown.

You can also view all of your exact keyword combinations using the Visitors > User Defined report.

October 22, 2008 11:01 AM

Aidin said:

How does this differ from the filter hack? Which one is better?

November 4, 2008 6:04 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Aidin: Check out my first article when I first created the script for how it differs from Omega's filter hack. I like the script better for the reasons outlined there.

November 5, 2008 1:32 PM

Gavin Doolan said:

Hi there,
I wonder if its possible to concatenate search queries to the user defined value to see data before the last click. (preventing a last click wins scenario)

What I mean is see the string of keywords used before a purchase. Say during the buyer research phase, till the point of purchase?

Obviously there is also the issue of previous campaigns which triggered a visit such as banner / email but I figured this may be the place to mention such an idea.

I've only just started to learn JS myself, perhaps by the time I'm finished reading my current book I'll have an idea on how to do it myself.

Cheers,
Gavin.

November 12, 2008 5:00 AM

Mike said:

Hello Michael,

Are you aware of this Advanced Filter setup that shows the bid keyword + exact search query?

http://www.ga-experts.com/blog/2006/11/how-to-get-detailed-ppc-keyword-data-from-google-analytics/

If so can you comment on the advantages/disadvantages of yours vs. theirs?

One thing that comes to mind is that theirs leaves the User Defined variable free for another utilization.

Thanks!
Mike

November 18, 2008 4:05 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Gavin: It's definitely possible. We've been working on something very similar here. Good luck on your own JS pursuits! Let us know if you post something about this elsewhere and we'll be sure to give you some link love.

November 19, 2008 3:11 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Mike: Definitely. It was Brian's filter that inspired me. The only issue I had with their is how it works on return visits to sites. See my original article for a full explanation.

November 19, 2008 3:13 PM

Aidin said:

Is there a way to implement this script to another profile?The first profile is already using the user defined field by live person chat. Could the two coexist within the same profile?

November 26, 2008 4:03 PM

Bud Gibson said:

How does this play with something like advanced segmentation? I was looking at those reports, and they seem to show what percentage of your search traffic for a given keyword is from paid sources.

The one thing I can see is that I might be able to see how my keywords are broad matching to actual search terms.

December 9, 2008 8:36 AM

Amit said:

Hi Michael,

Awesome post!
I was wondering if combining all the javascript in to a single .js file would be ok?

ON THE WEBPAGE YOUR WOULD PUT:

THE CONTENTS ON MyGA.js WOULD LOOK AS FOLLOWS:

var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));

function noPercent(x)
{
x = unescape(x);
return x.replace(/\+/g," ").replace(/^\s\s*/, '').replace(/\s\s*$/, '');
}

function getRef()
{
ref = document.referrer;
re = /(\?|&)(q|p|query|encquery|qt|terms|rdata|qs|wd|text|szukaj|k|searchExpr|
search_for|string|search_query|searchfor)=([^&]+)/;
searchq = re.exec(ref);
if(searchq) {
searchq[3] = noPercent(searchq[3]);
sleuthTracker._setVar(searchq[3]);
}
else {
sleuthTracker._setVar('Referral: ' + document.referrer);
}
}

function sleuth()
{
if(document.location.search.indexOf("gclid")!=-1||
document.location.search.indexOf("cpc")!=-1) {
getRef();
}
}

var sleuthTracker = _gat._getTracker("UA-1");
sleuthTracker._initData();
sleuth();

var pageTracker = _gat._getTracker("UA-XXXXXX-1");
pageTracker._initData();
pageTracker._trackPageview();

December 24, 2008 4:45 AM

Amit said:

no worries, I figured out why they need to be seperate. Thanks!

December 24, 2008 5:16 AM

rookie said:

The script works great!!
Can somebody help me to modify the script to append the ip of the user next to the search string? This would be invaluable for our statistical analysis. Unfortunately my javascript knowledge is limited. Thanks in advance!

January 4, 2009 6:22 PM

Bud Gibson said:

I just installed this script. An observation: why didn't you name space it? That would eliminate almost all possibilities of javascript conflict which I noticed one commenter remarking. I may do that myself if I get some spare time. It just involves encapsulating your functions in an object with a particular name. You then access the functions with Object.functionName().

January 7, 2009 10:37 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Amit: Yep, there's a reason why they're separate, though you can wrangle the JavaScript in such a way that there's only a single reference for all Google Analytics code, if you wanted to.

January 29, 2009 1:37 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@rookie: Glad the script is working for you!

As pulling IP addresses into Google Analytics actually violates the terms and conditions (and is impossible to do with JavaScript alone), there are currently no plans to add this functionality to the script.

January 29, 2009 1:43 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Bud: We have been testing a version of this script internally that expands on the features and uses object-oriented coding, but you're welcome to post your own.

January 29, 2009 1:50 PM

satin jain said:

but where i put this code..

i m new about this stuff...

please tell me where i have two put this script ...

please tell me...

February 13, 2009 2:55 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@satin jain: Just replace the exiting Google Analytics code, wherever it is on the page, with the one in the box.

February 13, 2009 3:17 PM

Brian Kaldenberg said:

I have installed everything and it appears to be tracking exact keywords correctly.

Problem is when inside analytics if I click the "clicks" tab, none of the clicks, impressions, ctr, cost, etc. data is showing up for dimension user-defined.

I have auto-link tag set to on.

Clicks data shows up for my broad match adgroup, but isn't the point of exact keyword tracking to be able to see clicks data for exact keywords within broad match?

I sure hope it is possible.

February 27, 2009 1:58 AM

Nikki said:

Hi

Is there a way of relating the keyword input to the keyword bid on? e.g. a hybrid of yours and Brian Cliftons PPC terms methods (his override bid term filter). So that a client can see e.g. car parking (car+parking+greater+manchester) using the ga2.js file?

Thanks
Nikki

March 16, 2009 8:54 AM

Richie Rich said:

Hi Michael. I have been successfully using the code here on 6 PPC accounts and the information has proved invaluable - thx so much for this.
However today on 2 of my 6 accounts I have no adwords data showing in my analytics? (and therefor no excat keyword tracking. Have you experienced this before - it may very well be an adwords glitch? Any ideas?

March 25, 2009 8:26 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Richie: No idea why it's not working. Have you checked to make sure that your AdWords linking and cost data is all set up properly?

March 25, 2009 3:20 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Nikki: It seems like it would be possible using filters. Give it a go and let us know how it works out.

March 25, 2009 3:24 PM

Medela Dude said:

Hi Mike, appreciate your work on this and have been using it for a year or 2 now.

Any news on a resolution to the "Not Set" issue?

May 6, 2009 10:51 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Medela Dude: Not yet. There's just a lot of traffic from Google that doesn't match the standard query. We'll definitely keep everyone posted with any updates to the code. Be sure to add the ROI blog to your reader of choice or subscribe via email with the link at the top right.

May 6, 2009 2:27 PM

Salman said:

I have implemented the script. Works fine. It returns the actual KWs in the user defined reports, however there is no goal conversions associated with these KWs although i know that i have made conversions through these KWs.

May 15, 2009 12:17 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Salman: Try drilling down to the keyword level in the Keywords report where you should see your conversions. Then segment by User Defined. What do you see?

May 15, 2009 9:57 AM

Neal said:

Michael, does this keyword filter affect GA ecommerce data? I recently installed it in one of my sites...I see the specific queries from Adwords but don't see conversion data. Our overall ecommerce stats also show $0 revenue right after installing the GA code.

June 19, 2009 7:39 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Neal: It shouldn't affect ecommerce data. What happens when you remove it?

June 22, 2009 11:53 AM

Neal said:

Michael,

We installed the code and all ecommerce data stopped reporting. We were averaging several $30,000 in revenue per day and then it went to $0 after we changed the GA code. Any ideas?

June 24, 2009 9:57 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Neal: Have you tried using the Exact Keyword Tracking script on all pages but your receipt page?

June 25, 2009 4:58 PM

Vince said:

Can someone explain how we can embed this data into our Website forms so the search keywords and PPC data is added to our leads please?

Basically, trying to achieve the same as what Salesforce.com Google adwords integration has with their web-to-lead form.
http://www.semgeek.com/semgeek/2008/03/what-you-need-t.html

July 18, 2009 9:49 AM

neal@akamaiseo.com said:


Michael, are you saying that the modified GA script needs to be on every page of your site except for your confirmation/receipt page?

July 20, 2009 3:51 PM

afzal hanif said:

Really great post, thanx. Right now i'm using the alternate 'filter method' to show the true keywords, however, conversions are still only attributed to the original (adwords) keyword. Perhaps I overlooked, but will this javascript method also show conversions to the true keywords? Hope you can help me, thanx:)

August 6, 2009 3:55 AM

afzal hanif said:

Nice post. I have been using the alternate mode now for a while, but one issue with this: conversions are not attributed to the 'true keywords', but to the keyword defined in adwords. Will this method show actual conversions to the true keywords? Perhaps I missed it but thanx in advance:)!

August 11, 2009 10:44 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Afzal: Yes, it will. One benefit it has over the other method. Just be sure to use the user defined report.

August 19, 2009 10:22 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Neal: Technically it should be on every possible landing page. You can write conditional JavaScript to check and see whether or not this is this case, or you can just put it on every page. Either way works, really.

August 19, 2009 10:32 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Vince: That's a bit more complicated. Justin Cutroni has detailed a method for something similar at his blog. Hope it helps!

August 19, 2009 10:36 AM

Jen said:

thanks Michael and ROIRev. This one gave us substantial savings over a twelve month period.

September 4, 2009 4:51 AM

Guy said:

Great stuff!!
Any way to fix it to show utf-8 keywords?

October 9, 2009 11:26 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Guy: To be honest, I haven't spent a lot of time working on the script. If you'd like to add decoding for utf-8, please feel free! Just let us know of any updates so we can share the wealth.

October 9, 2009 1:24 PM

Riedel Wine Glass said:

So should this script be on every page in the website? sorry newbie question

December 22, 2009 3:18 PM

Wytze said:

Thanks a million Michael,

Your script has made our year! Like somebody else mentioned earlier. This information is invaluable! Only running for a couple of days and I've already seen so many incorrect queries!

I do have a question though, is there a way to associate costs to the queries like you see with Search Query reports in Adwords?

Thanks again so much and have an early merry christmas! :)

December 23, 2009 7:00 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Riedel: Yes, put it on every page of your site. It should replace the standard Google Analytics Tracking Code.

January 4, 2010 5:55 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Wytze: No, there's not currently a way to associate costs with the queries. We typically just use the SQR in AdWords to do that.

January 4, 2010 5:57 PM

David Ogletree said:

I used to work at a ppc agency and our Google rep gave me a filter that let me track search partners. I did not save the filter and I don't have access to that account anymore. I can't seem to find how to do this again. Can you make a filter that does this?

January 12, 2010 9:46 AM

GregBB said:

What would be the reasons to favor the ga.js update to view actual search phrases in comparison to applying the "Override Bid Term" filters? Is the result the same? One obvious reason is that you can instantly apply it to all profiles, which could also be a disincentive if you would like to have more flexibility. Would appreciate your thoughts. Thanks!

February 4, 2010 8:01 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@David: You can add a query parameter to your destination URLs and then use the special AdWords macro {placement} to insert the URL that the ad was displayed on, like so:

www.mysite.com?site={placement}

Then you can use something like Filters, Site Search or Custom Variables to pull that data out and put it into a Google Analytics report.

March 6, 2010 4:18 PM

Kevin Joyner said:

Hi Michael

I seem to have gathered the impression from somewhere that there are plans ultimately to deprecate the GA user defined variable, and that we should use custom variables where possible.

Would it be worthwhile to adapt your Keyword Sleuth script to use custom variables? If so, I don't suppose you've done that, have you? :-)

Many thanks

Kevin

April 20, 2010 9:00 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Kevin: We have, and it works just fine. Look for an article about it in the near future.

April 20, 2010 11:10 AM

Sandra said:

Ok...pardon the moron. I have read this entire thread and just want to make sure I understand completely b4 I implement the code.

1. I literally just REPLACE the code on my sites with the one up top u provide (obviously changing the profile numbers)?

2. Do I have to also upload this ga_keyword2.js file? If so, why?

Thanks so much - really looking 4ward to taking it for a test drive!

S

May 19, 2010 3:55 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Sandra: Yes, replace the code on your site with the one above. And, yes, you do need to upload the file. Why? Because that's where all the code that grabs the search query is.

May 25, 2010 9:42 AM

Eric said:

Hi Michael,

I wanted to thank you for this wonderful tool. We've been using it for almost 2 years and its benefit has been significant.

Yesterday, I upgraded my site to the new asynchronous GATC code but wasn't quite sure how to integrate ga_keyword.js so I took my best shot as shown below. No luck--the user defined value data has disappeared.

Actually, there are two problems here. Whenever I originally set up the 'traditional' GATC code with the two additional lines for cross-domain tracking, the UDV info would disappeared. We decided knowing what the original queries were outweighed cross domain tracking so we just left out the

pageTracker._setDomainName('none');
pageTracker._setAllowLinker(true);

lines and lived with the compromise. This time I included the asynchronous equivalent for cross domain hoping it would work but no luck.

_gaq.push(['_setDomainName', 'none']);
_gaq.push(['_setAllowLinker', true]);

So I've changed too many variables to know what the real problem is, but if this is a no-brainer for you, would you please point out my error. Alternately, I can go back and remove the cross domain asynchronous lines to try and isolate the cause and effect and see what happens.

Also noticed an early post about deprecating the _setVar() function and an upcoming post about that? Perhaps that post might be nearby?

Would be grateful for any help.

Eric.

Current Attempt:

<!--
<head>

<script src="ga_keyword.js" type="text/javascript"></script>

<script type="text/javascript">

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-123456-1']);

_gaq.push(['_setDomainName', 'none']);
_gaq.push(['_setAllowLinker', true]);

_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

</script>

</head>
-->

July 7, 2010 9:00 AM

Darrell said:

Google Adwords lets me generate a report of keyphrases typed that caused ads to show up and wheter they generated clicks or not. These are phrases typed during the search, including searches on other sites, not just the keyword that match the ad. I can then see phrases generating clicks that I don't like the words that are in them, then ad those to my negative keywords. Is this something new that was not available in 2008 when this ga_keyword script was created?

September 8, 2010 5:52 PM

George Strait Tickets said:

Then you can use something like Filters, Site Search or Custom Variables to pull that data out and put it into a Google Analytics report.

September 23, 2010 5:58 AM

Christina said:

I used to work at a ppc agency and our Google rep gave me a filter that let me track search partners. I did not save the filter and I don't have access to that account anymore. I can't seem to find how to do this again. Can you make a filter that does this

October 26, 2010 8:58 AM

PPC Whiz said:

This stuff is great! Keep up the good work team, I really appreciate you sharing this with the community. You are an excellent resource for us PPC guys out there looking to maximize our spend.
My clients will thank you!

February 14, 2008 3:25 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@PPC Whiz: Glad we could help out! Definitely keep posted here on any additions or updates, and like I said in my post, our own team will be posting some of their tips and tricks in the coming weeks.

February 14, 2008 4:22 PM

Jesse DaCosta said:

Hey Michael,

Thanks for the update, have been on the lookout for it! I've tried another method from another blog but that doesn't seem to work, at least for me, so now I've updated to the new code I'm going to test this out.

Thanks again!

February 14, 2008 4:37 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Jesse: Great! Let me know how it works for you. We're always trying to improve it.

February 14, 2008 5:54 PM

Christian Martin said:

Thanks for updating the ga.js script with this! I only saw the original change for the old urchin code yesterday after your webinar. I've already changed the GA code on both our site and looking forward to seeing the results in the coming days.

I do have a question... In the Traffic Sources::Keywords section, their are toggles for Show: total | paid | non-paid and then the Segment listbox.

On first glance, it would seem GA is providing everything without the script. Am I being simplistic in my cursory look?

Thanks again!

February 14, 2008 7:06 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Christian: Unfortunately, the Keywords report will only show you the bid terms for your paid search. Basically, it will show you the keyword phrase that you bid upon, but not the one that visitors actually typed into the search engine. Hope that makes sense.

February 15, 2008 9:32 AM

Dave Cardwell said:

Thanks for updating this script and sharing it with the community.

I'm curious - why the "UA-1" in this line of the script:
_gat._getTracker("UA-1");

February 15, 2008 11:51 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Dave: It's just a precaution, due to the way that setVar operates, and we've found that it leads to more accurate usage stats.

February 15, 2008 1:57 PM

Searchquant said:

Doesn't it seem strange that Google wouldn't make this a feature in G Analytics early on? It's clear any smart marketer's gonna want to know which queries within phrase or broad matched keywords are working and not working.

Google gets 70% of its revenue from phrase and broad match.

February 15, 2008 4:53 PM

Sonja Bakker said:

Hi,

This quiet cool. I already saw that the previous script wasn't working anymore. Going to try this one now!

February 18, 2008 11:27 AM

Julien Raby said:

Hi Michael,

thanks a lot for this new version of the script, I was using the old filter hacks but it doesn't work anymore...

One question: the script as it is now doesn't seem to work if I manually tag my link (I almost always tag my links instead of using the auto-tagging to gain more control over the utm_campaign variable...) so I was wondering if there were a quick fix fo manual link tagger like myself?

Thanks again,
Julien

February 19, 2008 6:54 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Julien: While we definitely don't recommend that you manually tag AdWords ads (it causes problems when Analytics links up the data between your two accounts), this method should work for manually tagged links, so long as those links are tagged with utm_medium=cpc and the visits are coming from a search engine with a plainly visible search query in the URL (e.g., q=search+query, p=search+query, query=search+query).

February 22, 2008 3:28 PM

Chris Bradley said:

Thanks for this, I just tried the other method last week and didn't get it to work so this comes at a great time for me but I do have one question..

Should I upload the script to my root directory?

February 24, 2008 2:41 PM

Shawn Purtell, Senior Web Analytics Engineer Author Profile Page said:

@Chris:

You can upload the file wherever you like. Most websites have a specific place where scripts are stored, but it's different for everybody. The important thing is to make sure the call to the .js script is pointing to the right place.

February 25, 2008 9:29 AM

Charles Meaden said:

The actual ga_keyword2.js script contains the following lines


var pageTracker = _gat._getTracker("UA-XXXXXX-X");

The page says not to edit the script, but should I be changing the [yoursitehere] and UA-XXXX lines so that they correspond to our tracking codes?

March 17, 2008 10:40 AM

Jeremy Aube, Director of Engineering Author Profile Page said:

@Charles: Those lines are just a re-iteration of the installation instructions as given in the article. They are just comments, so you don't need to change it.

March 18, 2008 10:48 AM

Charles Meaden said:

Jeremy,

Thank you. Two more questions if I may.

1. Does it make any difference if I have amended the code to use our details
2. Can I use remove the commented section from the ga_keyword2.js file then

March 19, 2008 6:55 AM

Jeremy Aube, Director of Engineering Author Profile Page said:

@Charles: You really shouldn't be making any changes to the javascript file. If you're just making changes to or removing the comment section, that won't affect the functionality of the script, but it would be best to leave it as is. Then anyone who looks at the script will have the version number, author, general instructions (rather than specific to a single site's setup), and when it was last modified. Any changes to the script itself could negatively affect its functionality. Michael has written this script very precisely so that it needs no modification to work with your site.

March 19, 2008 9:52 AM

Ron said:

ok, I really want to get this data from my analytics and I have upgraded to ga and installed the tracking code...but I can't for the life of me understand where I find the detailed keyword search data in my analytics account. Can someone point me in the right direction?

April 2, 2008 4:21 PM

Jeremy Aube, Director of Engineering Author Profile Page said:

@Ron: The Exact Keyword Data for the site will be in the User Defined Report. You can also segment various reports by the User Defined Variable to see this information for specific visitor traffic segments. See Michael's previous post for more information.

April 2, 2008 4:39 PM

Ron said:

So if I look in the tab "Visitor/UserDefined" and all I see under the user defined values is "not set" then it's safe to assume I screwed up in inserting the tracking code?

April 2, 2008 5:35 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Ron: Well, it either means that you screwed up, or that you don't have any paid search traffic coming into your site. The traffic has to be auto-tagged AdWords clicks or manually tagged clicks with utm_medium=cpc.

Good luck!

April 3, 2008 10:59 AM

Ryan said:

Okay, I feel like an idiot.

The code checks out fine. Analytics is otherwise tracking fine. And I am getting my adwords PPC traffic to come up.

But STILL, I'm only getting "not set".

Is there something I'm missing? Maybe something obscenely obvious?

Thanks so much!

June 3, 2008 10:06 AM

Ryan said:

Yup. I'm definitely an idiot.

1. Didn't change the .js src path.

2. Didn't upload the .js file.

June 3, 2008 10:34 AM

Eric said:

Thanks for making these scripts. I put them on my site about a week ago, and the info has been very valuable.

Unfortunately, about 50% of the data comes back as (not set) and a slightly better return of only 33% on Yahoo. I don't have my account autotagged for various reasons, but every keyword has it's own URL with utm_medium=cpc. Is this the normal capture for the script or perhaps I have done something wrong or does the order of the utm_ variables in the search string matter. Currently I set the source, medium, campaign and then the term.

Thanks again for this wonderful tool.

June 10, 2008 2:36 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Eric: Well, content network will never display a search query, and some of the search partner sites don't format the search query in the same way that Google does. 50% is about the norm for what I see.

If you can find the search network sites that your ads are running and provide them, I may be able to expand the script to use their search queries.

June 10, 2008 4:27 PM

Daniel Waisberg said:

Hi Michael,

Thank you very much for the feature it is wonderful.

I was wondering if this code can work together with the one created by John Henson from LunaMetrics: Stuff More Than One Value into GA\x92s User Defined Segment . If so, this would solve the issue of using other User Defined Variables together with it.

Thank you again.

June 22, 2008 4:05 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Daniel: I don't see why the two scripts wouldn't play nice together. :) It may require some modifications to the JavaScript. Give it a shot and let us know how it works out.

June 24, 2008 8:24 AM

Eran Malloch said:

Hi Michael,

I REALLY REALLY REALLY need this tool to work (great idea and thanks to all who developed it), but unfortunately, whenever I add it to a site created by our webdesign partners, it somehow interferes with the script that creates their drop-down menu system, and the menu system stops working... :(

This has happened on 2 seperate sites now, and obviously we have to remove your script because a non-working menu system just aint gonna cut it. ;)

I'm guessing if this is happening to me, there are probably others it is happening to as well, but perhaps they haven't bothered to contact you and mention it.

ANY help you (or anyone else reading this comment) can provide with this issue would be GREATLY appreciated. I am happy to email you the offending site urls, etc.

Thanks in advance for your time, and I really do appreciate your efforts to provide this vital tool (and bah humbug to Google for NOT providing it) ;)


Eran Malloch
WCR Internet Marketing
Perth, Western Australia

July 11, 2008 2:22 AM

wil said:

How do I create a report that shows side-by-side the keyword in the AdWords campaign that was triggered along with the user defined variable (the search term). Right now, under traffic sources, I can see one or the other.

Thanks,

Wil

July 12, 2008 2:27 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Eran: I'd check to make sure that none of the functions from the menu system interfere with the keyword script. Beyond that, I don't see why it would cause any problems. Because of the sheer number of setups and JavaScript present on websites, there's no possible way we can troubleshoot each individual issue with the script, but if you have any additional comments on precisely what is going on (error messages, etc.), then maybe we can help out.

July 21, 2008 1:29 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Wil: There is no such report, but you could create a new profile with an Advanced Filter that plugs the User Defined field into the Campaign Term field. Just cram 'em both together, and that way when you look at your keywords list, you would see:

"bid term (search term)"

This will mean that cost and click data for your AdWords Campaigns keyword report will not match up properly, thus the reason why I recommend creating an additional profile.

Hope that helps.

July 21, 2008 1:36 PM

Eric Werner said:

Hi and thanks! One quick question, what does this do?

pageTracker._initData();

This line isn't in the code that Google gave me and you didn't mention anything about it in the post so I wanted to check.

Thanks!

August 8, 2008 12:18 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Eric: pageTracker._initData() is a deprecated function that was previously required before running the Google Analytics pageTracker. You can get rid of it or keep it in; entirely up to you.

August 8, 2008 1:52 PM

Jason said:

Michael - I've modified a function in the ga_keyword2.js code that I find quite useful re: more accurate stats gathering:

function noPercent(x)
{
x = unescape(x);
x = x.replace(/\+/g," ").replace(/^\s\s*/, '').replace(/\s\s*$/, '');
return x.toLowerCase(); // added feature
}


this basically groups all upper & lower case variations so that I get an accurate picture of the number of people using a particular word or phrase. Great script!

August 14, 2008 9:44 PM

Ricky said:

I think that this script looks great, and I have just updated the script on our site to check it out.

Though one question still remains, how does this differ from the report you get out of Adwords that shows you which search results that triggered your adwords to show and generate a click?

Thanks!

August 19, 2008 8:14 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Ricky: Check out my co-worker Mark Curtis' article on the Keyword Sleuth script versus the AdWords Search Query Performance Report for the answer to your question.

August 19, 2008 10:17 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Jason: Thanks for the info. You could also use a lowercase filter inside of Google Analytics if you don't want to modify the code (if, for instance, it's already installed on your site).

August 19, 2008 10:19 AM

Eric S said:

Michael, thanks again for this wonderful script. I recently upgraded to the new tracking code and the script worked fine. Unfortunately, my 'check-out' is handled by a third party that is still running the legacy script and they are hesitant to upgrade. Note that their legacy script also has

_udn="none";
_ulink=1;

in the legacy code to enable cross-domain tracking.

So, I downgraded back to the legacy code and added the two lines for cross-domain tracking code that I had not used before, and the next day all of my User Defined Value data was missing. So I deleted the

_udn="none";
_ulink=1;

lines and it immediately returned but this left me without the cross domain tracking I had hoped to gain. Note that the User Defined Value came through just fine in the ga.js version except the link was broken across the domains due to code incompatability. Any suggestions for getting the legacy version to work cross-domain. I noticed that the slueth(); function was in the legacy code on your first blog in 07 but not the more recent blog. Might this be part of it?

On a completely separate issue, I appended the cpc search term that actually responded to the original user query to the UDV and was stunned at the level of mismatch. For example, I had a phrase/exact match bid for "word1 word2 word3 word4", the user queried the exact term "word1 word2 word3 word4" but Google responded to the query with a broad matched term "word1 word2 wordX" where wordX was barely a synonym but the price point was much higher--not to mention the ad displayed to the user's query was far less relevant because the reponse came from a different ad group. Google does this a lot.

Do you see this mis-matching to increase Search Engine revenues a lot and does your consulting service offer methods of combating this problem of what seems a lot like fraud?

August 31, 2008 8:45 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Eric S: As long as you properly tag links between domains with utmLinker, you should be fine. It should bridge the gap between domains with the right cookie information.

Good luck!

September 2, 2008 3:24 PM

Mike said:

Hi Michael,

I am on the ROI GA Online training.

I have installed the Sleuth Tracking code, but I get "(not set)" when I go check the User Defined data.

I cannot spot what I am doing wrong.

You can view my code in the source of this page:

http://www.enquete-satisfaction.com/

Thanks for your help!
Mike

October 6, 2008 9:06 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Mike: The ga_keyword2.js file must go between the first <script> section of the Google Analytics Tracking Code and the second. You have it before. Please read the article again and be sure to place it in precisely the spot that I indicated. That should fix it for you.

You also should be wary of "smart" or curled quotes showing up in your code. If you use Microsoft Outlook or Word to edit code with quotation marks and paste it into your site, you might end up with a left or a right curled quote (“ or ”) instead of a standard quote ("). Be sure to only use standard quote marks in HTML code.

October 6, 2008 11:03 AM

Mike said:

Michael,

Could it be that I had copied the code from an older version of the article?

I am asking since my code also includes Sleuth() at the end, that the new code doesn't seem to include.

Thanks for your help!
Mike

October 8, 2008 9:52 AM

Eddy said:

This is a great script that I have been using flawlessly for a while now, but for the past month or so, all the keywords within the user defined page are still attached to the Google search query that is after the q variable as in http://www.google.co.uk/search?hl=en&q=keyword1+keyword2&meta=
I dont understand why this has started happening but could do with some advice.

thanks
eddy

October 8, 2008 11:43 AM

Eddy said:

Michael, if not done so already is it possible to add the search queries for the following Google search network partners?
aolsearch.aol.co.uk
www.winbuyer.co.uk
search.babylon.com
www.kellysearch.co.uk
business.shop.ebay.co.uk
search.virginmedia.com
www.hotfroguk.co.uk
uk.ask.com
www.tiscali.co.uk
search1.sky.com
search.mywebsearch.com

there are quite a few more but they generate just one or two visits.

regards
eddy

October 8, 2008 12:35 PM

art said:

Great script. Cant wait to see the results.

October 12, 2008 10:35 PM

Mike said:

Hi Michael,

I got the script to work. However, there are 2 issues:

1) About 20-25% of the visits show as "not set" (I don't use content for that campaign, only search with Google & Search Network).

Can you tell what they could account for?

2) It's a campaign with French keywords and the script doesn't capture the accents properly (whereas GA's Traffic Sources > Keyword Report does). E.g. the word "pr\xE9vention" shows as "prévention".

Is there a way to correct that?

Thanks!
Mike

October 13, 2008 8:04 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Mike: The reason why 20-25% of your visits are "not set" is because the script currently does not account for all of the engines that are a part of the Google search network. We've been working on an update for that, which should be released in the next few days, and should reduce the percentage of "not sets".

We'll also work on getting the accents fixed. Thanks for letting me know!

October 14, 2008 10:42 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Eddy: I'm not really sure what you mean by this. Can you illustrate with a screenshot or a URL?

October 14, 2008 10:45 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Eddy: I've been working on the script, trying to increase the number of search engine query parameters that it recognizes. Thanks for your list, and look for an update over the next few days.

October 14, 2008 10:46 AM

art said:

Great tool! I have started to see the results and they are amazing. 80% of my visits are showing as "not set". Are they all as a results of google parters not being included or because I haven't set utm_medium=ppc for both yahoo and msn ppc traffic? the interesting part is the bulk of our revenue is coming from google partners/or the other engines...the "not set" portion.

Second question..I want to add another domain which is an add-on to the main domain..Do I follow the exact steps for additional domains.

October 15, 2008 12:42 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Art: It could be because you haven't set utm_medium=cpc for Yahoo! and MSN paid traffic. Many Google partners aren't included yet, either, but I'll be posting an update to the script that will contain more of those partners. Keep an eye out on the blog, or subscribe to it to keep up-to-date.

October 15, 2008 10:26 AM

Clikckbank Affiliates said:

Thanks for the update...

October 20, 2008 3:14 PM

Moses Chang said:

Hi, just stumbled upon this tool and immediately created a new Google Analytics account for our website and installed it. Do I lose the ability to track AdWords Campaigns (under the Traffic Sources tab in Google Analytics) once this tool is installed? I also can't find where the search query info are being displayed...

Thanks in advance,
Moses

October 22, 2008 10:46 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Moses: This won't affect your AdWords Campaigns report and won't take away your ability to track campaigns, adgroups, or keywords. To access the exact keyword information, you can either drill down to a specific campaign/adgroup/keyword in the Traffic Sources > AdWords > AdWords Campaigns report and use the Dimension User Defined dropdown.

You can also view all of your exact keyword combinations using the Visitors > User Defined report.

October 22, 2008 11:01 AM

Aidin said:

How does this differ from the filter hack? Which one is better?

November 4, 2008 6:04 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Aidin: Check out my first article when I first created the script for how it differs from Omega's filter hack. I like the script better for the reasons outlined there.

November 5, 2008 1:32 PM

Gavin Doolan said:

Hi there,
I wonder if its possible to concatenate search queries to the user defined value to see data before the last click. (preventing a last click wins scenario)

What I mean is see the string of keywords used before a purchase. Say during the buyer research phase, till the point of purchase?

Obviously there is also the issue of previous campaigns which triggered a visit such as banner / email but I figured this may be the place to mention such an idea.

I've only just started to learn JS myself, perhaps by the time I'm finished reading my current book I'll have an idea on how to do it myself.

Cheers,
Gavin.

November 12, 2008 5:00 AM

Mike said:

Hello Michael,

Are you aware of this Advanced Filter setup that shows the bid keyword + exact search query?

http://www.ga-experts.com/blog/2006/11/how-to-get-detailed-ppc-keyword-data-from-google-analytics/

If so can you comment on the advantages/disadvantages of yours vs. theirs?

One thing that comes to mind is that theirs leaves the User Defined variable free for another utilization.

Thanks!
Mike

November 18, 2008 4:05 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Gavin: It's definitely possible. We've been working on something very similar here. Good luck on your own JS pursuits! Let us know if you post something about this elsewhere and we'll be sure to give you some link love.

November 19, 2008 3:11 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Mike: Definitely. It was Brian's filter that inspired me. The only issue I had with their is how it works on return visits to sites. See my original article for a full explanation.

November 19, 2008 3:13 PM

Aidin said:

Is there a way to implement this script to another profile?The first profile is already using the user defined field by live person chat. Could the two coexist within the same profile?

November 26, 2008 4:03 PM

Bud Gibson said:

How does this play with something like advanced segmentation? I was looking at those reports, and they seem to show what percentage of your search traffic for a given keyword is from paid sources.

The one thing I can see is that I might be able to see how my keywords are broad matching to actual search terms.

December 9, 2008 8:36 AM

Amit said:

Hi Michael,

Awesome post!
I was wondering if combining all the javascript in to a single .js file would be ok?

ON THE WEBPAGE YOUR WOULD PUT:

THE CONTENTS ON MyGA.js WOULD LOOK AS FOLLOWS:

var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));

function noPercent(x)
{
x = unescape(x);
return x.replace(/\+/g," ").replace(/^\s\s*/, '').replace(/\s\s*$/, '');
}

function getRef()
{
ref = document.referrer;
re = /(\?|&)(q|p|query|encquery|qt|terms|rdata|qs|wd|text|szukaj|k|searchExpr|
search_for|string|search_query|searchfor)=([^&]+)/;
searchq = re.exec(ref);
if(searchq) {
searchq[3] = noPercent(searchq[3]);
sleuthTracker._setVar(searchq[3]);
}
else {
sleuthTracker._setVar('Referral: ' + document.referrer);
}
}

function sleuth()
{
if(document.location.search.indexOf("gclid")!=-1||
document.location.search.indexOf("cpc")!=-1) {
getRef();
}
}

var sleuthTracker = _gat._getTracker("UA-1");
sleuthTracker._initData();
sleuth();

var pageTracker = _gat._getTracker("UA-XXXXXX-1");
pageTracker._initData();
pageTracker._trackPageview();

December 24, 2008 4:45 AM

Amit said:

no worries, I figured out why they need to be seperate. Thanks!

December 24, 2008 5:16 AM

rookie said:

The script works great!!
Can somebody help me to modify the script to append the ip of the user next to the search string? This would be invaluable for our statistical analysis. Unfortunately my javascript knowledge is limited. Thanks in advance!

January 4, 2009 6:22 PM

Bud Gibson said:

I just installed this script. An observation: why didn't you name space it? That would eliminate almost all possibilities of javascript conflict which I noticed one commenter remarking. I may do that myself if I get some spare time. It just involves encapsulating your functions in an object with a particular name. You then access the functions with Object.functionName().

January 7, 2009 10:37 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Amit: Yep, there's a reason why they're separate, though you can wrangle the JavaScript in such a way that there's only a single reference for all Google Analytics code, if you wanted to.

January 29, 2009 1:37 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@rookie: Glad the script is working for you!

As pulling IP addresses into Google Analytics actually violates the terms and conditions (and is impossible to do with JavaScript alone), there are currently no plans to add this functionality to the script.

January 29, 2009 1:43 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Bud: We have been testing a version of this script internally that expands on the features and uses object-oriented coding, but you're welcome to post your own.

January 29, 2009 1:50 PM

satin jain said:

but where i put this code..

i m new about this stuff...

please tell me where i have two put this script ...

please tell me...

February 13, 2009 2:55 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@satin jain: Just replace the exiting Google Analytics code, wherever it is on the page, with the one in the box.

February 13, 2009 3:17 PM

Brian Kaldenberg said:

I have installed everything and it appears to be tracking exact keywords correctly.

Problem is when inside analytics if I click the "clicks" tab, none of the clicks, impressions, ctr, cost, etc. data is showing up for dimension user-defined.

I have auto-link tag set to on.

Clicks data shows up for my broad match adgroup, but isn't the point of exact keyword tracking to be able to see clicks data for exact keywords within broad match?

I sure hope it is possible.

February 27, 2009 1:58 AM

Nikki said:

Hi

Is there a way of relating the keyword input to the keyword bid on? e.g. a hybrid of yours and Brian Cliftons PPC terms methods (his override bid term filter). So that a client can see e.g. car parking (car+parking+greater+manchester) using the ga2.js file?

Thanks
Nikki

March 16, 2009 8:54 AM

Richie Rich said:

Hi Michael. I have been successfully using the code here on 6 PPC accounts and the information has proved invaluable - thx so much for this.
However today on 2 of my 6 accounts I have no adwords data showing in my analytics? (and therefor no excat keyword tracking. Have you experienced this before - it may very well be an adwords glitch? Any ideas?

March 25, 2009 8:26 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Richie: No idea why it's not working. Have you checked to make sure that your AdWords linking and cost data is all set up properly?

March 25, 2009 3:20 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Nikki: It seems like it would be possible using filters. Give it a go and let us know how it works out.

March 25, 2009 3:24 PM

Medela Dude said:

Hi Mike, appreciate your work on this and have been using it for a year or 2 now.

Any news on a resolution to the "Not Set" issue?

May 6, 2009 10:51 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Medela Dude: Not yet. There's just a lot of traffic from Google that doesn't match the standard query. We'll definitely keep everyone posted with any updates to the code. Be sure to add the ROI blog to your reader of choice or subscribe via email with the link at the top right.

May 6, 2009 2:27 PM

Salman said:

I have implemented the script. Works fine. It returns the actual KWs in the user defined reports, however there is no goal conversions associated with these KWs although i know that i have made conversions through these KWs.

May 15, 2009 12:17 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Salman: Try drilling down to the keyword level in the Keywords report where you should see your conversions. Then segment by User Defined. What do you see?

May 15, 2009 9:57 AM

Neal said:

Michael, does this keyword filter affect GA ecommerce data? I recently installed it in one of my sites...I see the specific queries from Adwords but don't see conversion data. Our overall ecommerce stats also show $0 revenue right after installing the GA code.

June 19, 2009 7:39 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Neal: It shouldn't affect ecommerce data. What happens when you remove it?

June 22, 2009 11:53 AM

Neal said:

Michael,

We installed the code and all ecommerce data stopped reporting. We were averaging several $30,000 in revenue per day and then it went to $0 after we changed the GA code. Any ideas?

June 24, 2009 9:57 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Neal: Have you tried using the Exact Keyword Tracking script on all pages but your receipt page?

June 25, 2009 4:58 PM

Vince said:

Can someone explain how we can embed this data into our Website forms so the search keywords and PPC data is added to our leads please?

Basically, trying to achieve the same as what Salesforce.com Google adwords integration has with their web-to-lead form.
http://www.semgeek.com/semgeek/2008/03/what-you-need-t.html

July 18, 2009 9:49 AM

neal@akamaiseo.com said:


Michael, are you saying that the modified GA script needs to be on every page of your site except for your confirmation/receipt page?

July 20, 2009 3:51 PM

afzal hanif said:

Really great post, thanx. Right now i'm using the alternate 'filter method' to show the true keywords, however, conversions are still only attributed to the original (adwords) keyword. Perhaps I overlooked, but will this javascript method also show conversions to the true keywords? Hope you can help me, thanx:)

August 6, 2009 3:55 AM

afzal hanif said:

Nice post. I have been using the alternate mode now for a while, but one issue with this: conversions are not attributed to the 'true keywords', but to the keyword defined in adwords. Will this method show actual conversions to the true keywords? Perhaps I missed it but thanx in advance:)!

August 11, 2009 10:44 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Afzal: Yes, it will. One benefit it has over the other method. Just be sure to use the user defined report.

August 19, 2009 10:22 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Neal: Technically it should be on every possible landing page. You can write conditional JavaScript to check and see whether or not this is this case, or you can just put it on every page. Either way works, really.

August 19, 2009 10:32 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Vince: That's a bit more complicated. Justin Cutroni has detailed a method for something similar at his blog. Hope it helps!

August 19, 2009 10:36 AM

Jen said:

thanks Michael and ROIRev. This one gave us substantial savings over a twelve month period.

September 4, 2009 4:51 AM

Guy said:

Great stuff!!
Any way to fix it to show utf-8 keywords?

October 9, 2009 11:26 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Guy: To be honest, I haven't spent a lot of time working on the script. If you'd like to add decoding for utf-8, please feel free! Just let us know of any updates so we can share the wealth.

October 9, 2009 1:24 PM

Riedel Wine Glass said:

So should this script be on every page in the website? sorry newbie question

December 22, 2009 3:18 PM

Wytze said:

Thanks a million Michael,

Your script has made our year! Like somebody else mentioned earlier. This information is invaluable! Only running for a couple of days and I've already seen so many incorrect queries!

I do have a question though, is there a way to associate costs to the queries like you see with Search Query reports in Adwords?

Thanks again so much and have an early merry christmas! :)

December 23, 2009 7:00 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Riedel: Yes, put it on every page of your site. It should replace the standard Google Analytics Tracking Code.

January 4, 2010 5:55 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Wytze: No, there's not currently a way to associate costs with the queries. We typically just use the SQR in AdWords to do that.

January 4, 2010 5:57 PM

David Ogletree said:

I used to work at a ppc agency and our Google rep gave me a filter that let me track search partners. I did not save the filter and I don't have access to that account anymore. I can't seem to find how to do this again. Can you make a filter that does this?

January 12, 2010 9:46 AM

GregBB said:

What would be the reasons to favor the ga.js update to view actual search phrases in comparison to applying the "Override Bid Term" filters? Is the result the same? One obvious reason is that you can instantly apply it to all profiles, which could also be a disincentive if you would like to have more flexibility. Would appreciate your thoughts. Thanks!

February 4, 2010 8:01 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@David: You can add a query parameter to your destination URLs and then use the special AdWords macro {placement} to insert the URL that the ad was displayed on, like so:

www.mysite.com?site={placement}

Then you can use something like Filters, Site Search or Custom Variables to pull that data out and put it into a Google Analytics report.

March 6, 2010 4:18 PM

Kevin Joyner said:

Hi Michael

I seem to have gathered the impression from somewhere that there are plans ultimately to deprecate the GA user defined variable, and that we should use custom variables where possible.

Would it be worthwhile to adapt your Keyword Sleuth script to use custom variables? If so, I don't suppose you've done that, have you? :-)

Many thanks

Kevin

April 20, 2010 9:00 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Kevin: We have, and it works just fine. Look for an article about it in the near future.

April 20, 2010 11:10 AM

Sandra said:

Ok...pardon the moron. I have read this entire thread and just want to make sure I understand completely b4 I implement the code.

1. I literally just REPLACE the code on my sites with the one up top u provide (obviously changing the profile numbers)?

2. Do I have to also upload this ga_keyword2.js file? If so, why?

Thanks so much - really looking 4ward to taking it for a test drive!

S

May 19, 2010 3:55 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Sandra: Yes, replace the code on your site with the one above. And, yes, you do need to upload the file. Why? Because that's where all the code that grabs the search query is.

May 25, 2010 9:42 AM

Eric said:

Hi Michael,

I wanted to thank you for this wonderful tool. We've been using it for almost 2 years and its benefit has been significant.

Yesterday, I upgraded my site to the new asynchronous GATC code but wasn't quite sure how to integrate ga_keyword.js so I took my best shot as shown below. No luck--the user defined value data has disappeared.

Actually, there are two problems here. Whenever I originally set up the 'traditional' GATC code with the two additional lines for cross-domain tracking, the UDV info would disappeared. We decided knowing what the original queries were outweighed cross domain tracking so we just left out the

pageTracker._setDomainName('none');
pageTracker._setAllowLinker(true);

lines and lived with the compromise. This time I included the asynchronous equivalent for cross domain hoping it would work but no luck.

_gaq.push(['_setDomainName', 'none']);
_gaq.push(['_setAllowLinker', true]);

So I've changed too many variables to know what the real problem is, but if this is a no-brainer for you, would you please point out my error. Alternately, I can go back and remove the cross domain asynchronous lines to try and isolate the cause and effect and see what happens.

Also noticed an early post about deprecating the _setVar() function and an upcoming post about that? Perhaps that post might be nearby?

Would be grateful for any help.

Eric.

Current Attempt:

<!--
<head>

<script src="ga_keyword.js" type="text/javascript"></script>

<script type="text/javascript">

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-123456-1']);

_gaq.push(['_setDomainName', 'none']);
_gaq.push(['_setAllowLinker', true]);

_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

</script>

</head>
-->

July 7, 2010 9:00 AM

Darrell said:

Google Adwords lets me generate a report of keyphrases typed that caused ads to show up and wheter they generated clicks or not. These are phrases typed during the search, including searches on other sites, not just the keyword that match the ad. I can then see phrases generating clicks that I don't like the words that are in them, then ad those to my negative keywords. Is this something new that was not available in 2008 when this ga_keyword script was created?

September 8, 2010 5:52 PM

George Strait Tickets said:

Then you can use something like Filters, Site Search or Custom Variables to pull that data out and put it into a Google Analytics report.

September 23, 2010 5:58 AM

Christina said:

I used to work at a ppc agency and our Google rep gave me a filter that let me track search partners. I did not save the filter and I don't have access to that account anymore. I can't seem to find how to do this again. Can you make a filter that does this

October 26, 2010 8:58 AM

PPC Whiz said:

This stuff is great! Keep up the good work team, I really appreciate you sharing this with the community. You are an excellent resource for us PPC guys out there looking to maximize our spend.
My clients will thank you!

February 14, 2008 3:25 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@PPC Whiz: Glad we could help out! Definitely keep posted here on any additions or updates, and like I said in my post, our own team will be posting some of their tips and tricks in the coming weeks.

February 14, 2008 4:22 PM

Jesse DaCosta said:

Hey Michael,

Thanks for the update, have been on the lookout for it! I've tried another method from another blog but that doesn't seem to work, at least for me, so now I've updated to the new code I'm going to test this out.

Thanks again!

February 14, 2008 4:37 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Jesse: Great! Let me know how it works for you. We're always trying to improve it.

February 14, 2008 5:54 PM

Christian Martin said:

Thanks for updating the ga.js script with this! I only saw the original change for the old urchin code yesterday after your webinar. I've already changed the GA code on both our site and looking forward to seeing the results in the coming days.

I do have a question... In the Traffic Sources::Keywords section, their are toggles for Show: total | paid | non-paid and then the Segment listbox.

On first glance, it would seem GA is providing everything without the script. Am I being simplistic in my cursory look?

Thanks again!

February 14, 2008 7:06 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Christian: Unfortunately, the Keywords report will only show you the bid terms for your paid search. Basically, it will show you the keyword phrase that you bid upon, but not the one that visitors actually typed into the search engine. Hope that makes sense.

February 15, 2008 9:32 AM

Dave Cardwell said:

Thanks for updating this script and sharing it with the community.

I'm curious - why the "UA-1" in this line of the script:
_gat._getTracker("UA-1");

February 15, 2008 11:51 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Dave: It's just a precaution, due to the way that setVar operates, and we've found that it leads to more accurate usage stats.

February 15, 2008 1:57 PM

Searchquant said:

Doesn't it seem strange that Google wouldn't make this a feature in G Analytics early on? It's clear any smart marketer's gonna want to know which queries within phrase or broad matched keywords are working and not working.

Google gets 70% of its revenue from phrase and broad match.

February 15, 2008 4:53 PM

Sonja Bakker said:

Hi,

This quiet cool. I already saw that the previous script wasn't working anymore. Going to try this one now!

February 18, 2008 11:27 AM

Julien Raby said:

Hi Michael,

thanks a lot for this new version of the script, I was using the old filter hacks but it doesn't work anymore...

One question: the script as it is now doesn't seem to work if I manually tag my link (I almost always tag my links instead of using the auto-tagging to gain more control over the utm_campaign variable...) so I was wondering if there were a quick fix fo manual link tagger like myself?

Thanks again,
Julien

February 19, 2008 6:54 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Julien: While we definitely don't recommend that you manually tag AdWords ads (it causes problems when Analytics links up the data between your two accounts), this method should work for manually tagged links, so long as those links are tagged with utm_medium=cpc and the visits are coming from a search engine with a plainly visible search query in the URL (e.g., q=search+query, p=search+query, query=search+query).

February 22, 2008 3:28 PM

Chris Bradley said:

Thanks for this, I just tried the other method last week and didn't get it to work so this comes at a great time for me but I do have one question..

Should I upload the script to my root directory?

February 24, 2008 2:41 PM

Shawn Purtell, Senior Web Analytics Engineer Author Profile Page said:

@Chris:

You can upload the file wherever you like. Most websites have a specific place where scripts are stored, but it's different for everybody. The important thing is to make sure the call to the .js script is pointing to the right place.

February 25, 2008 9:29 AM

Charles Meaden said:

The actual ga_keyword2.js script contains the following lines


var pageTracker = _gat._getTracker("UA-XXXXXX-X");

The page says not to edit the script, but should I be changing the [yoursitehere] and UA-XXXX lines so that they correspond to our tracking codes?

March 17, 2008 10:40 AM

Jeremy Aube, Director of Engineering Author Profile Page said:

@Charles: Those lines are just a re-iteration of the installation instructions as given in the article. They are just comments, so you don't need to change it.

March 18, 2008 10:48 AM

Charles Meaden said:

Jeremy,

Thank you. Two more questions if I may.

1. Does it make any difference if I have amended the code to use our details
2. Can I use remove the commented section from the ga_keyword2.js file then

March 19, 2008 6:55 AM

Jeremy Aube, Director of Engineering Author Profile Page said:

@Charles: You really shouldn't be making any changes to the javascript file. If you're just making changes to or removing the comment section, that won't affect the functionality of the script, but it would be best to leave it as is. Then anyone who looks at the script will have the version number, author, general instructions (rather than specific to a single site's setup), and when it was last modified. Any changes to the script itself could negatively affect its functionality. Michael has written this script very precisely so that it needs no modification to work with your site.

March 19, 2008 9:52 AM

Ron said:

ok, I really want to get this data from my analytics and I have upgraded to ga and installed the tracking code...but I can't for the life of me understand where I find the detailed keyword search data in my analytics account. Can someone point me in the right direction?

April 2, 2008 4:21 PM

Jeremy Aube, Director of Engineering Author Profile Page said:

@Ron: The Exact Keyword Data for the site will be in the User Defined Report. You can also segment various reports by the User Defined Variable to see this information for specific visitor traffic segments. See Michael's previous post for more information.

April 2, 2008 4:39 PM

Ron said:

So if I look in the tab "Visitor/UserDefined" and all I see under the user defined values is "not set" then it's safe to assume I screwed up in inserting the tracking code?

April 2, 2008 5:35 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Ron: Well, it either means that you screwed up, or that you don't have any paid search traffic coming into your site. The traffic has to be auto-tagged AdWords clicks or manually tagged clicks with utm_medium=cpc.

Good luck!

April 3, 2008 10:59 AM

Ryan said:

Okay, I feel like an idiot.

The code checks out fine. Analytics is otherwise tracking fine. And I am getting my adwords PPC traffic to come up.

But STILL, I'm only getting "not set".

Is there something I'm missing? Maybe something obscenely obvious?

Thanks so much!

June 3, 2008 10:06 AM

Ryan said:

Yup. I'm definitely an idiot.

1. Didn't change the .js src path.

2. Didn't upload the .js file.

June 3, 2008 10:34 AM

Eric said:

Thanks for making these scripts. I put them on my site about a week ago, and the info has been very valuable.

Unfortunately, about 50% of the data comes back as (not set) and a slightly better return of only 33% on Yahoo. I don't have my account autotagged for various reasons, but every keyword has it's own URL with utm_medium=cpc. Is this the normal capture for the script or perhaps I have done something wrong or does the order of the utm_ variables in the search string matter. Currently I set the source, medium, campaign and then the term.

Thanks again for this wonderful tool.

June 10, 2008 2:36 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Eric: Well, content network will never display a search query, and some of the search partner sites don't format the search query in the same way that Google does. 50% is about the norm for what I see.

If you can find the search network sites that your ads are running and provide them, I may be able to expand the script to use their search queries.

June 10, 2008 4:27 PM

Daniel Waisberg said:

Hi Michael,

Thank you very much for the feature it is wonderful.

I was wondering if this code can work together with the one created by John Henson from LunaMetrics: Stuff More Than One Value into GA\x92s User Defined Segment . If so, this would solve the issue of using other User Defined Variables together with it.

Thank you again.

June 22, 2008 4:05 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Daniel: I don't see why the two scripts wouldn't play nice together. :) It may require some modifications to the JavaScript. Give it a shot and let us know how it works out.

June 24, 2008 8:24 AM

Eran Malloch said:

Hi Michael,

I REALLY REALLY REALLY need this tool to work (great idea and thanks to all who developed it), but unfortunately, whenever I add it to a site created by our webdesign partners, it somehow interferes with the script that creates their drop-down menu system, and the menu system stops working... :(

This has happened on 2 seperate sites now, and obviously we have to remove your script because a non-working menu system just aint gonna cut it. ;)

I'm guessing if this is happening to me, there are probably others it is happening to as well, but perhaps they haven't bothered to contact you and mention it.

ANY help you (or anyone else reading this comment) can provide with this issue would be GREATLY appreciated. I am happy to email you the offending site urls, etc.

Thanks in advance for your time, and I really do appreciate your efforts to provide this vital tool (and bah humbug to Google for NOT providing it) ;)


Eran Malloch
WCR Internet Marketing
Perth, Western Australia

July 11, 2008 2:22 AM

wil said:

How do I create a report that shows side-by-side the keyword in the AdWords campaign that was triggered along with the user defined variable (the search term). Right now, under traffic sources, I can see one or the other.

Thanks,

Wil

July 12, 2008 2:27 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Eran: I'd check to make sure that none of the functions from the menu system interfere with the keyword script. Beyond that, I don't see why it would cause any problems. Because of the sheer number of setups and JavaScript present on websites, there's no possible way we can troubleshoot each individual issue with the script, but if you have any additional comments on precisely what is going on (error messages, etc.), then maybe we can help out.

July 21, 2008 1:29 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Wil: There is no such report, but you could create a new profile with an Advanced Filter that plugs the User Defined field into the Campaign Term field. Just cram 'em both together, and that way when you look at your keywords list, you would see:

"bid term (search term)"

This will mean that cost and click data for your AdWords Campaigns keyword report will not match up properly, thus the reason why I recommend creating an additional profile.

Hope that helps.

July 21, 2008 1:36 PM

Eric Werner said:

Hi and thanks! One quick question, what does this do?

pageTracker._initData();

This line isn't in the code that Google gave me and you didn't mention anything about it in the post so I wanted to check.

Thanks!

August 8, 2008 12:18 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Eric: pageTracker._initData() is a deprecated function that was previously required before running the Google Analytics pageTracker. You can get rid of it or keep it in; entirely up to you.

August 8, 2008 1:52 PM

Jason said:

Michael - I've modified a function in the ga_keyword2.js code that I find quite useful re: more accurate stats gathering:

function noPercent(x)
{
x = unescape(x);
x = x.replace(/\+/g," ").replace(/^\s\s*/, '').replace(/\s\s*$/, '');
return x.toLowerCase(); // added feature
}


this basically groups all upper & lower case variations so that I get an accurate picture of the number of people using a particular word or phrase. Great script!

August 14, 2008 9:44 PM

Ricky said:

I think that this script looks great, and I have just updated the script on our site to check it out.

Though one question still remains, how does this differ from the report you get out of Adwords that shows you which search results that triggered your adwords to show and generate a click?

Thanks!

August 19, 2008 8:14 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Ricky: Check out my co-worker Mark Curtis' article on the Keyword Sleuth script versus the AdWords Search Query Performance Report for the answer to your question.

August 19, 2008 10:17 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Jason: Thanks for the info. You could also use a lowercase filter inside of Google Analytics if you don't want to modify the code (if, for instance, it's already installed on your site).

August 19, 2008 10:19 AM

Eric S said:

Michael, thanks again for this wonderful script. I recently upgraded to the new tracking code and the script worked fine. Unfortunately, my 'check-out' is handled by a third party that is still running the legacy script and they are hesitant to upgrade. Note that their legacy script also has

_udn="none";
_ulink=1;

in the legacy code to enable cross-domain tracking.

So, I downgraded back to the legacy code and added the two lines for cross-domain tracking code that I had not used before, and the next day all of my User Defined Value data was missing. So I deleted the

_udn="none";
_ulink=1;

lines and it immediately returned but this left me without the cross domain tracking I had hoped to gain. Note that the User Defined Value came through just fine in the ga.js version except the link was broken across the domains due to code incompatability. Any suggestions for getting the legacy version to work cross-domain. I noticed that the slueth(); function was in the legacy code on your first blog in 07 but not the more recent blog. Might this be part of it?

On a completely separate issue, I appended the cpc search term that actually responded to the original user query to the UDV and was stunned at the level of mismatch. For example, I had a phrase/exact match bid for "word1 word2 word3 word4", the user queried the exact term "word1 word2 word3 word4" but Google responded to the query with a broad matched term "word1 word2 wordX" where wordX was barely a synonym but the price point was much higher--not to mention the ad displayed to the user's query was far less relevant because the reponse came from a different ad group. Google does this a lot.

Do you see this mis-matching to increase Search Engine revenues a lot and does your consulting service offer methods of combating this problem of what seems a lot like fraud?

August 31, 2008 8:45 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Eric S: As long as you properly tag links between domains with utmLinker, you should be fine. It should bridge the gap between domains with the right cookie information.

Good luck!

September 2, 2008 3:24 PM

Mike said:

Hi Michael,

I am on the ROI GA Online training.

I have installed the Sleuth Tracking code, but I get "(not set)" when I go check the User Defined data.

I cannot spot what I am doing wrong.

You can view my code in the source of this page:

http://www.enquete-satisfaction.com/

Thanks for your help!
Mike

October 6, 2008 9:06 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Mike: The ga_keyword2.js file must go between the first <script> section of the Google Analytics Tracking Code and the second. You have it before. Please read the article again and be sure to place it in precisely the spot that I indicated. That should fix it for you.

You also should be wary of "smart" or curled quotes showing up in your code. If you use Microsoft Outlook or Word to edit code with quotation marks and paste it into your site, you might end up with a left or a right curled quote (“ or ”) instead of a standard quote ("). Be sure to only use standard quote marks in HTML code.

October 6, 2008 11:03 AM

Mike said:

Michael,

Could it be that I had copied the code from an older version of the article?

I am asking since my code also includes Sleuth() at the end, that the new code doesn't seem to include.

Thanks for your help!
Mike

October 8, 2008 9:52 AM

Eddy said:

This is a great script that I have been using flawlessly for a while now, but for the past month or so, all the keywords within the user defined page are still attached to the Google search query that is after the q variable as in http://www.google.co.uk/search?hl=en&q=keyword1+keyword2&meta=
I dont understand why this has started happening but could do with some advice.

thanks
eddy

October 8, 2008 11:43 AM

Eddy said:

Michael, if not done so already is it possible to add the search queries for the following Google search network partners?
aolsearch.aol.co.uk
www.winbuyer.co.uk
search.babylon.com
www.kellysearch.co.uk
business.shop.ebay.co.uk
search.virginmedia.com
www.hotfroguk.co.uk
uk.ask.com
www.tiscali.co.uk
search1.sky.com
search.mywebsearch.com

there are quite a few more but they generate just one or two visits.

regards
eddy

October 8, 2008 12:35 PM

art said:

Great script. Cant wait to see the results.

October 12, 2008 10:35 PM

Mike said:

Hi Michael,

I got the script to work. However, there are 2 issues:

1) About 20-25% of the visits show as "not set" (I don't use content for that campaign, only search with Google & Search Network).

Can you tell what they could account for?

2) It's a campaign with French keywords and the script doesn't capture the accents properly (whereas GA's Traffic Sources > Keyword Report does). E.g. the word "pr\xE9vention" shows as "prévention".

Is there a way to correct that?

Thanks!
Mike

October 13, 2008 8:04 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Mike: The reason why 20-25% of your visits are "not set" is because the script currently does not account for all of the engines that are a part of the Google search network. We've been working on an update for that, which should be released in the next few days, and should reduce the percentage of "not sets".

We'll also work on getting the accents fixed. Thanks for letting me know!

October 14, 2008 10:42 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Eddy: I'm not really sure what you mean by this. Can you illustrate with a screenshot or a URL?

October 14, 2008 10:45 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Eddy: I've been working on the script, trying to increase the number of search engine query parameters that it recognizes. Thanks for your list, and look for an update over the next few days.

October 14, 2008 10:46 AM

art said:

Great tool! I have started to see the results and they are amazing. 80% of my visits are showing as "not set". Are they all as a results of google parters not being included or because I haven't set utm_medium=ppc for both yahoo and msn ppc traffic? the interesting part is the bulk of our revenue is coming from google partners/or the other engines...the "not set" portion.

Second question..I want to add another domain which is an add-on to the main domain..Do I follow the exact steps for additional domains.

October 15, 2008 12:42 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Art: It could be because you haven't set utm_medium=cpc for Yahoo! and MSN paid traffic. Many Google partners aren't included yet, either, but I'll be posting an update to the script that will contain more of those partners. Keep an eye out on the blog, or subscribe to it to keep up-to-date.

October 15, 2008 10:26 AM

Clikckbank Affiliates said:

Thanks for the update...

October 20, 2008 3:14 PM

Moses Chang said:

Hi, just stumbled upon this tool and immediately created a new Google Analytics account for our website and installed it. Do I lose the ability to track AdWords Campaigns (under the Traffic Sources tab in Google Analytics) once this tool is installed? I also can't find where the search query info are being displayed...

Thanks in advance,
Moses

October 22, 2008 10:46 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Moses: This won't affect your AdWords Campaigns report and won't take away your ability to track campaigns, adgroups, or keywords. To access the exact keyword information, you can either drill down to a specific campaign/adgroup/keyword in the Traffic Sources > AdWords > AdWords Campaigns report and use the Dimension User Defined dropdown.

You can also view all of your exact keyword combinations using the Visitors > User Defined report.

October 22, 2008 11:01 AM

Aidin said:

How does this differ from the filter hack? Which one is better?

November 4, 2008 6:04 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Aidin: Check out my first article when I first created the script for how it differs from Omega's filter hack. I like the script better for the reasons outlined there.

November 5, 2008 1:32 PM

Gavin Doolan said:

Hi there,
I wonder if its possible to concatenate search queries to the user defined value to see data before the last click. (preventing a last click wins scenario)

What I mean is see the string of keywords used before a purchase. Say during the buyer research phase, till the point of purchase?

Obviously there is also the issue of previous campaigns which triggered a visit such as banner / email but I figured this may be the place to mention such an idea.

I've only just started to learn JS myself, perhaps by the time I'm finished reading my current book I'll have an idea on how to do it myself.

Cheers,
Gavin.

November 12, 2008 5:00 AM

Mike said:

Hello Michael,

Are you aware of this Advanced Filter setup that shows the bid keyword + exact search query?

http://www.ga-experts.com/blog/2006/11/how-to-get-detailed-ppc-keyword-data-from-google-analytics/

If so can you comment on the advantages/disadvantages of yours vs. theirs?

One thing that comes to mind is that theirs leaves the User Defined variable free for another utilization.

Thanks!
Mike

November 18, 2008 4:05 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Gavin: It's definitely possible. We've been working on something very similar here. Good luck on your own JS pursuits! Let us know if you post something about this elsewhere and we'll be sure to give you some link love.

November 19, 2008 3:11 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Mike: Definitely. It was Brian's filter that inspired me. The only issue I had with their is how it works on return visits to sites. See my original article for a full explanation.

November 19, 2008 3:13 PM

Aidin said:

Is there a way to implement this script to another profile?The first profile is already using the user defined field by live person chat. Could the two coexist within the same profile?

November 26, 2008 4:03 PM

Bud Gibson said:

How does this play with something like advanced segmentation? I was looking at those reports, and they seem to show what percentage of your search traffic for a given keyword is from paid sources.

The one thing I can see is that I might be able to see how my keywords are broad matching to actual search terms.

December 9, 2008 8:36 AM

Amit said:

Hi Michael,

Awesome post!
I was wondering if combining all the javascript in to a single .js file would be ok?

ON THE WEBPAGE YOUR WOULD PUT:

THE CONTENTS ON MyGA.js WOULD LOOK AS FOLLOWS:

var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));

function noPercent(x)
{
x = unescape(x);
return x.replace(/\+/g," ").replace(/^\s\s*/, '').replace(/\s\s*$/, '');
}

function getRef()
{
ref = document.referrer;
re = /(\?|&)(q|p|query|encquery|qt|terms|rdata|qs|wd|text|szukaj|k|searchExpr|
search_for|string|search_query|searchfor)=([^&]+)/;
searchq = re.exec(ref);
if(searchq) {
searchq[3] = noPercent(searchq[3]);
sleuthTracker._setVar(searchq[3]);
}
else {
sleuthTracker._setVar('Referral: ' + document.referrer);
}
}

function sleuth()
{
if(document.location.search.indexOf("gclid")!=-1||
document.location.search.indexOf("cpc")!=-1) {
getRef();
}
}

var sleuthTracker = _gat._getTracker("UA-1");
sleuthTracker._initData();
sleuth();

var pageTracker = _gat._getTracker("UA-XXXXXX-1");
pageTracker._initData();
pageTracker._trackPageview();

December 24, 2008 4:45 AM

Amit said:

no worries, I figured out why they need to be seperate. Thanks!

December 24, 2008 5:16 AM

rookie said:

The script works great!!
Can somebody help me to modify the script to append the ip of the user next to the search string? This would be invaluable for our statistical analysis. Unfortunately my javascript knowledge is limited. Thanks in advance!

January 4, 2009 6:22 PM

Bud Gibson said:

I just installed this script. An observation: why didn't you name space it? That would eliminate almost all possibilities of javascript conflict which I noticed one commenter remarking. I may do that myself if I get some spare time. It just involves encapsulating your functions in an object with a particular name. You then access the functions with Object.functionName().

January 7, 2009 10:37 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Amit: Yep, there's a reason why they're separate, though you can wrangle the JavaScript in such a way that there's only a single reference for all Google Analytics code, if you wanted to.

January 29, 2009 1:37 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@rookie: Glad the script is working for you!

As pulling IP addresses into Google Analytics actually violates the terms and conditions (and is impossible to do with JavaScript alone), there are currently no plans to add this functionality to the script.

January 29, 2009 1:43 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Bud: We have been testing a version of this script internally that expands on the features and uses object-oriented coding, but you're welcome to post your own.

January 29, 2009 1:50 PM

satin jain said:

but where i put this code..

i m new about this stuff...

please tell me where i have two put this script ...

please tell me...

February 13, 2009 2:55 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@satin jain: Just replace the exiting Google Analytics code, wherever it is on the page, with the one in the box.

February 13, 2009 3:17 PM

Brian Kaldenberg said:

I have installed everything and it appears to be tracking exact keywords correctly.

Problem is when inside analytics if I click the "clicks" tab, none of the clicks, impressions, ctr, cost, etc. data is showing up for dimension user-defined.

I have auto-link tag set to on.

Clicks data shows up for my broad match adgroup, but isn't the point of exact keyword tracking to be able to see clicks data for exact keywords within broad match?

I sure hope it is possible.

February 27, 2009 1:58 AM

Nikki said:

Hi

Is there a way of relating the keyword input to the keyword bid on? e.g. a hybrid of yours and Brian Cliftons PPC terms methods (his override bid term filter). So that a client can see e.g. car parking (car+parking+greater+manchester) using the ga2.js file?

Thanks
Nikki

March 16, 2009 8:54 AM

Richie Rich said:

Hi Michael. I have been successfully using the code here on 6 PPC accounts and the information has proved invaluable - thx so much for this.
However today on 2 of my 6 accounts I have no adwords data showing in my analytics? (and therefor no excat keyword tracking. Have you experienced this before - it may very well be an adwords glitch? Any ideas?

March 25, 2009 8:26 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Richie: No idea why it's not working. Have you checked to make sure that your AdWords linking and cost data is all set up properly?

March 25, 2009 3:20 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Nikki: It seems like it would be possible using filters. Give it a go and let us know how it works out.

March 25, 2009 3:24 PM

Medela Dude said:

Hi Mike, appreciate your work on this and have been using it for a year or 2 now.

Any news on a resolution to the "Not Set" issue?

May 6, 2009 10:51 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Medela Dude: Not yet. There's just a lot of traffic from Google that doesn't match the standard query. We'll definitely keep everyone posted with any updates to the code. Be sure to add the ROI blog to your reader of choice or subscribe via email with the link at the top right.

May 6, 2009 2:27 PM

Salman said:

I have implemented the script. Works fine. It returns the actual KWs in the user defined reports, however there is no goal conversions associated with these KWs although i know that i have made conversions through these KWs.

May 15, 2009 12:17 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Salman: Try drilling down to the keyword level in the Keywords report where you should see your conversions. Then segment by User Defined. What do you see?

May 15, 2009 9:57 AM

Neal said:

Michael, does this keyword filter affect GA ecommerce data? I recently installed it in one of my sites...I see the specific queries from Adwords but don't see conversion data. Our overall ecommerce stats also show $0 revenue right after installing the GA code.

June 19, 2009 7:39 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Neal: It shouldn't affect ecommerce data. What happens when you remove it?

June 22, 2009 11:53 AM

Neal said:

Michael,

We installed the code and all ecommerce data stopped reporting. We were averaging several $30,000 in revenue per day and then it went to $0 after we changed the GA code. Any ideas?

June 24, 2009 9:57 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Neal: Have you tried using the Exact Keyword Tracking script on all pages but your receipt page?

June 25, 2009 4:58 PM

Vince said:

Can someone explain how we can embed this data into our Website forms so the search keywords and PPC data is added to our leads please?

Basically, trying to achieve the same as what Salesforce.com Google adwords integration has with their web-to-lead form.
http://www.semgeek.com/semgeek/2008/03/what-you-need-t.html

July 18, 2009 9:49 AM

neal@akamaiseo.com said:


Michael, are you saying that the modified GA script needs to be on every page of your site except for your confirmation/receipt page?

July 20, 2009 3:51 PM

afzal hanif said:

Really great post, thanx. Right now i'm using the alternate 'filter method' to show the true keywords, however, conversions are still only attributed to the original (adwords) keyword. Perhaps I overlooked, but will this javascript method also show conversions to the true keywords? Hope you can help me, thanx:)

August 6, 2009 3:55 AM

afzal hanif said:

Nice post. I have been using the alternate mode now for a while, but one issue with this: conversions are not attributed to the 'true keywords', but to the keyword defined in adwords. Will this method show actual conversions to the true keywords? Perhaps I missed it but thanx in advance:)!

August 11, 2009 10:44 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Afzal: Yes, it will. One benefit it has over the other method. Just be sure to use the user defined report.

August 19, 2009 10:22 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Neal: Technically it should be on every possible landing page. You can write conditional JavaScript to check and see whether or not this is this case, or you can just put it on every page. Either way works, really.

August 19, 2009 10:32 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Vince: That's a bit more complicated. Justin Cutroni has detailed a method for something similar at his blog. Hope it helps!

August 19, 2009 10:36 AM

Jen said:

thanks Michael and ROIRev. This one gave us substantial savings over a twelve month period.

September 4, 2009 4:51 AM

Guy said:

Great stuff!!
Any way to fix it to show utf-8 keywords?

October 9, 2009 11:26 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Guy: To be honest, I haven't spent a lot of time working on the script. If you'd like to add decoding for utf-8, please feel free! Just let us know of any updates so we can share the wealth.

October 9, 2009 1:24 PM

Riedel Wine Glass said:

So should this script be on every page in the website? sorry newbie question

December 22, 2009 3:18 PM

Wytze said:

Thanks a million Michael,

Your script has made our year! Like somebody else mentioned earlier. This information is invaluable! Only running for a couple of days and I've already seen so many incorrect queries!

I do have a question though, is there a way to associate costs to the queries like you see with Search Query reports in Adwords?

Thanks again so much and have an early merry christmas! :)

December 23, 2009 7:00 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Riedel: Yes, put it on every page of your site. It should replace the standard Google Analytics Tracking Code.

January 4, 2010 5:55 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Wytze: No, there's not currently a way to associate costs with the queries. We typically just use the SQR in AdWords to do that.

January 4, 2010 5:57 PM

David Ogletree said:

I used to work at a ppc agency and our Google rep gave me a filter that let me track search partners. I did not save the filter and I don't have access to that account anymore. I can't seem to find how to do this again. Can you make a filter that does this?

January 12, 2010 9:46 AM

GregBB said:

What would be the reasons to favor the ga.js update to view actual search phrases in comparison to applying the "Override Bid Term" filters? Is the result the same? One obvious reason is that you can instantly apply it to all profiles, which could also be a disincentive if you would like to have more flexibility. Would appreciate your thoughts. Thanks!

February 4, 2010 8:01 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@David: You can add a query parameter to your destination URLs and then use the special AdWords macro {placement} to insert the URL that the ad was displayed on, like so:

www.mysite.com?site={placement}

Then you can use something like Filters, Site Search or Custom Variables to pull that data out and put it into a Google Analytics report.

March 6, 2010 4:18 PM

Kevin Joyner said:

Hi Michael

I seem to have gathered the impression from somewhere that there are plans ultimately to deprecate the GA user defined variable, and that we should use custom variables where possible.

Would it be worthwhile to adapt your Keyword Sleuth script to use custom variables? If so, I don't suppose you've done that, have you? :-)

Many thanks

Kevin

April 20, 2010 9:00 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Kevin: We have, and it works just fine. Look for an article about it in the near future.

April 20, 2010 11:10 AM

Sandra said:

Ok...pardon the moron. I have read this entire thread and just want to make sure I understand completely b4 I implement the code.

1. I literally just REPLACE the code on my sites with the one up top u provide (obviously changing the profile numbers)?

2. Do I have to also upload this ga_keyword2.js file? If so, why?

Thanks so much - really looking 4ward to taking it for a test drive!

S

May 19, 2010 3:55 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Sandra: Yes, replace the code on your site with the one above. And, yes, you do need to upload the file. Why? Because that's where all the code that grabs the search query is.

May 25, 2010 9:42 AM

Eric said:

Hi Michael,

I wanted to thank you for this wonderful tool. We've been using it for almost 2 years and its benefit has been significant.

Yesterday, I upgraded my site to the new asynchronous GATC code but wasn't quite sure how to integrate ga_keyword.js so I took my best shot as shown below. No luck--the user defined value data has disappeared.

Actually, there are two problems here. Whenever I originally set up the 'traditional' GATC code with the two additional lines for cross-domain tracking, the UDV info would disappeared. We decided knowing what the original queries were outweighed cross domain tracking so we just left out the

pageTracker._setDomainName('none');
pageTracker._setAllowLinker(true);

lines and lived with the compromise. This time I included the asynchronous equivalent for cross domain hoping it would work but no luck.

_gaq.push(['_setDomainName', 'none']);
_gaq.push(['_setAllowLinker', true]);

So I've changed too many variables to know what the real problem is, but if this is a no-brainer for you, would you please point out my error. Alternately, I can go back and remove the cross domain asynchronous lines to try and isolate the cause and effect and see what happens.

Also noticed an early post about deprecating the _setVar() function and an upcoming post about that? Perhaps that post might be nearby?

Would be grateful for any help.

Eric.

Current Attempt:

<!--
<head>

<script src="ga_keyword.js" type="text/javascript"></script>

<script type="text/javascript">

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-123456-1']);

_gaq.push(['_setDomainName', 'none']);
_gaq.push(['_setAllowLinker', true]);

_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

</script>

</head>
-->

July 7, 2010 9:00 AM

Darrell said:

Google Adwords lets me generate a report of keyphrases typed that caused ads to show up and wheter they generated clicks or not. These are phrases typed during the search, including searches on other sites, not just the keyword that match the ad. I can then see phrases generating clicks that I don't like the words that are in them, then ad those to my negative keywords. Is this something new that was not available in 2008 when this ga_keyword script was created?

September 8, 2010 5:52 PM

George Strait Tickets said:

Then you can use something like Filters, Site Search or Custom Variables to pull that data out and put it into a Google Analytics report.

September 23, 2010 5:58 AM

Christina said:

I used to work at a ppc agency and our Google rep gave me a filter that let me track search partners. I did not save the filter and I don't have access to that account anymore. I can't seem to find how to do this again. Can you make a filter that does this

October 26, 2010 8:58 AM

PPC Whiz said:

This stuff is great! Keep up the good work team, I really appreciate you sharing this with the community. You are an excellent resource for us PPC guys out there looking to maximize our spend.
My clients will thank you!

February 14, 2008 3:25 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@PPC Whiz: Glad we could help out! Definitely keep posted here on any additions or updates, and like I said in my post, our own team will be posting some of their tips and tricks in the coming weeks.

February 14, 2008 4:22 PM

Jesse DaCosta said:

Hey Michael,

Thanks for the update, have been on the lookout for it! I've tried another method from another blog but that doesn't seem to work, at least for me, so now I've updated to the new code I'm going to test this out.

Thanks again!

February 14, 2008 4:37 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Jesse: Great! Let me know how it works for you. We're always trying to improve it.

February 14, 2008 5:54 PM

Christian Martin said:

Thanks for updating the ga.js script with this! I only saw the original change for the old urchin code yesterday after your webinar. I've already changed the GA code on both our site and looking forward to seeing the results in the coming days.

I do have a question... In the Traffic Sources::Keywords section, their are toggles for Show: total | paid | non-paid and then the Segment listbox.

On first glance, it would seem GA is providing everything without the script. Am I being simplistic in my cursory look?

Thanks again!

February 14, 2008 7:06 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Christian: Unfortunately, the Keywords report will only show you the bid terms for your paid search. Basically, it will show you the keyword phrase that you bid upon, but not the one that visitors actually typed into the search engine. Hope that makes sense.

February 15, 2008 9:32 AM

Dave Cardwell said:

Thanks for updating this script and sharing it with the community.

I'm curious - why the "UA-1" in this line of the script:
_gat._getTracker("UA-1");

February 15, 2008 11:51 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Dave: It's just a precaution, due to the way that setVar operates, and we've found that it leads to more accurate usage stats.

February 15, 2008 1:57 PM

Searchquant said:

Doesn't it seem strange that Google wouldn't make this a feature in G Analytics early on? It's clear any smart marketer's gonna want to know which queries within phrase or broad matched keywords are working and not working.

Google gets 70% of its revenue from phrase and broad match.

February 15, 2008 4:53 PM

Sonja Bakker said:

Hi,

This quiet cool. I already saw that the previous script wasn't working anymore. Going to try this one now!

February 18, 2008 11:27 AM

Julien Raby said:

Hi Michael,

thanks a lot for this new version of the script, I was using the old filter hacks but it doesn't work anymore...

One question: the script as it is now doesn't seem to work if I manually tag my link (I almost always tag my links instead of using the auto-tagging to gain more control over the utm_campaign variable...) so I was wondering if there were a quick fix fo manual link tagger like myself?

Thanks again,
Julien

February 19, 2008 6:54 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Julien: While we definitely don't recommend that you manually tag AdWords ads (it causes problems when Analytics links up the data between your two accounts), this method should work for manually tagged links, so long as those links are tagged with utm_medium=cpc and the visits are coming from a search engine with a plainly visible search query in the URL (e.g., q=search+query, p=search+query, query=search+query).

February 22, 2008 3:28 PM

Chris Bradley said:

Thanks for this, I just tried the other method last week and didn't get it to work so this comes at a great time for me but I do have one question..

Should I upload the script to my root directory?

February 24, 2008 2:41 PM

Shawn Purtell, Senior Web Analytics Engineer Author Profile Page said:

@Chris:

You can upload the file wherever you like. Most websites have a specific place where scripts are stored, but it's different for everybody. The important thing is to make sure the call to the .js script is pointing to the right place.

February 25, 2008 9:29 AM

Charles Meaden said:

The actual ga_keyword2.js script contains the following lines


var pageTracker = _gat._getTracker("UA-XXXXXX-X");

The page says not to edit the script, but should I be changing the [yoursitehere] and UA-XXXX lines so that they correspond to our tracking codes?

March 17, 2008 10:40 AM

Jeremy Aube, Director of Engineering Author Profile Page said:

@Charles: Those lines are just a re-iteration of the installation instructions as given in the article. They are just comments, so you don't need to change it.

March 18, 2008 10:48 AM

Charles Meaden said:

Jeremy,

Thank you. Two more questions if I may.

1. Does it make any difference if I have amended the code to use our details
2. Can I use remove the commented section from the ga_keyword2.js file then

March 19, 2008 6:55 AM

Jeremy Aube, Director of Engineering Author Profile Page said:

@Charles: You really shouldn't be making any changes to the javascript file. If you're just making changes to or removing the comment section, that won't affect the functionality of the script, but it would be best to leave it as is. Then anyone who looks at the script will have the version number, author, general instructions (rather than specific to a single site's setup), and when it was last modified. Any changes to the script itself could negatively affect its functionality. Michael has written this script very precisely so that it needs no modification to work with your site.

March 19, 2008 9:52 AM

Ron said:

ok, I really want to get this data from my analytics and I have upgraded to ga and installed the tracking code...but I can't for the life of me understand where I find the detailed keyword search data in my analytics account. Can someone point me in the right direction?

April 2, 2008 4:21 PM

Jeremy Aube, Director of Engineering Author Profile Page said:

@Ron: The Exact Keyword Data for the site will be in the User Defined Report. You can also segment various reports by the User Defined Variable to see this information for specific visitor traffic segments. See Michael's previous post for more information.

April 2, 2008 4:39 PM

Ron said:

So if I look in the tab "Visitor/UserDefined" and all I see under the user defined values is "not set" then it's safe to assume I screwed up in inserting the tracking code?

April 2, 2008 5:35 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Ron: Well, it either means that you screwed up, or that you don't have any paid search traffic coming into your site. The traffic has to be auto-tagged AdWords clicks or manually tagged clicks with utm_medium=cpc.

Good luck!

April 3, 2008 10:59 AM

Ryan said:

Okay, I feel like an idiot.

The code checks out fine. Analytics is otherwise tracking fine. And I am getting my adwords PPC traffic to come up.

But STILL, I'm only getting "not set".

Is there something I'm missing? Maybe something obscenely obvious?

Thanks so much!

June 3, 2008 10:06 AM

Ryan said:

Yup. I'm definitely an idiot.

1. Didn't change the .js src path.

2. Didn't upload the .js file.

June 3, 2008 10:34 AM

Eric said:

Thanks for making these scripts. I put them on my site about a week ago, and the info has been very valuable.

Unfortunately, about 50% of the data comes back as (not set) and a slightly better return of only 33% on Yahoo. I don't have my account autotagged for various reasons, but every keyword has it's own URL with utm_medium=cpc. Is this the normal capture for the script or perhaps I have done something wrong or does the order of the utm_ variables in the search string matter. Currently I set the source, medium, campaign and then the term.

Thanks again for this wonderful tool.

June 10, 2008 2:36 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Eric: Well, content network will never display a search query, and some of the search partner sites don't format the search query in the same way that Google does. 50% is about the norm for what I see.

If you can find the search network sites that your ads are running and provide them, I may be able to expand the script to use their search queries.

June 10, 2008 4:27 PM

Daniel Waisberg said:

Hi Michael,

Thank you very much for the feature it is wonderful.

I was wondering if this code can work together with the one created by John Henson from LunaMetrics: Stuff More Than One Value into GA\x92s User Defined Segment . If so, this would solve the issue of using other User Defined Variables together with it.

Thank you again.

June 22, 2008 4:05 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Daniel: I don't see why the two scripts wouldn't play nice together. :) It may require some modifications to the JavaScript. Give it a shot and let us know how it works out.

June 24, 2008 8:24 AM

Eran Malloch said:

Hi Michael,

I REALLY REALLY REALLY need this tool to work (great idea and thanks to all who developed it), but unfortunately, whenever I add it to a site created by our webdesign partners, it somehow interferes with the script that creates their drop-down menu system, and the menu system stops working... :(

This has happened on 2 seperate sites now, and obviously we have to remove your script because a non-working menu system just aint gonna cut it. ;)

I'm guessing if this is happening to me, there are probably others it is happening to as well, but perhaps they haven't bothered to contact you and mention it.

ANY help you (or anyone else reading this comment) can provide with this issue would be GREATLY appreciated. I am happy to email you the offending site urls, etc.

Thanks in advance for your time, and I really do appreciate your efforts to provide this vital tool (and bah humbug to Google for NOT providing it) ;)


Eran Malloch
WCR Internet Marketing
Perth, Western Australia

July 11, 2008 2:22 AM

wil said:

How do I create a report that shows side-by-side the keyword in the AdWords campaign that was triggered along with the user defined variable (the search term). Right now, under traffic sources, I can see one or the other.

Thanks,

Wil

July 12, 2008 2:27 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Eran: I'd check to make sure that none of the functions from the menu system interfere with the keyword script. Beyond that, I don't see why it would cause any problems. Because of the sheer number of setups and JavaScript present on websites, there's no possible way we can troubleshoot each individual issue with the script, but if you have any additional comments on precisely what is going on (error messages, etc.), then maybe we can help out.

July 21, 2008 1:29 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Wil: There is no such report, but you could create a new profile with an Advanced Filter that plugs the User Defined field into the Campaign Term field. Just cram 'em both together, and that way when you look at your keywords list, you would see:

"bid term (search term)"

This will mean that cost and click data for your AdWords Campaigns keyword report will not match up properly, thus the reason why I recommend creating an additional profile.

Hope that helps.

July 21, 2008 1:36 PM

Eric Werner said:

Hi and thanks! One quick question, what does this do?

pageTracker._initData();

This line isn't in the code that Google gave me and you didn't mention anything about it in the post so I wanted to check.

Thanks!

August 8, 2008 12:18 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Eric: pageTracker._initData() is a deprecated function that was previously required before running the Google Analytics pageTracker. You can get rid of it or keep it in; entirely up to you.

August 8, 2008 1:52 PM

Jason said:

Michael - I've modified a function in the ga_keyword2.js code that I find quite useful re: more accurate stats gathering:

function noPercent(x)
{
x = unescape(x);
x = x.replace(/\+/g," ").replace(/^\s\s*/, '').replace(/\s\s*$/, '');
return x.toLowerCase(); // added feature
}


this basically groups all upper & lower case variations so that I get an accurate picture of the number of people using a particular word or phrase. Great script!

August 14, 2008 9:44 PM

Ricky said:

I think that this script looks great, and I have just updated the script on our site to check it out.

Though one question still remains, how does this differ from the report you get out of Adwords that shows you which search results that triggered your adwords to show and generate a click?

Thanks!

August 19, 2008 8:14 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Ricky: Check out my co-worker Mark Curtis' article on the Keyword Sleuth script versus the AdWords Search Query Performance Report for the answer to your question.

August 19, 2008 10:17 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Jason: Thanks for the info. You could also use a lowercase filter inside of Google Analytics if you don't want to modify the code (if, for instance, it's already installed on your site).

August 19, 2008 10:19 AM

Eric S said:

Michael, thanks again for this wonderful script. I recently upgraded to the new tracking code and the script worked fine. Unfortunately, my 'check-out' is handled by a third party that is still running the legacy script and they are hesitant to upgrade. Note that their legacy script also has

_udn="none";
_ulink=1;

in the legacy code to enable cross-domain tracking.

So, I downgraded back to the legacy code and added the two lines for cross-domain tracking code that I had not used before, and the next day all of my User Defined Value data was missing. So I deleted the

_udn="none";
_ulink=1;

lines and it immediately returned but this left me without the cross domain tracking I had hoped to gain. Note that the User Defined Value came through just fine in the ga.js version except the link was broken across the domains due to code incompatability. Any suggestions for getting the legacy version to work cross-domain. I noticed that the slueth(); function was in the legacy code on your first blog in 07 but not the more recent blog. Might this be part of it?

On a completely separate issue, I appended the cpc search term that actually responded to the original user query to the UDV and was stunned at the level of mismatch. For example, I had a phrase/exact match bid for "word1 word2 word3 word4", the user queried the exact term "word1 word2 word3 word4" but Google responded to the query with a broad matched term "word1 word2 wordX" where wordX was barely a synonym but the price point was much higher--not to mention the ad displayed to the user's query was far less relevant because the reponse came from a different ad group. Google does this a lot.

Do you see this mis-matching to increase Search Engine revenues a lot and does your consulting service offer methods of combating this problem of what seems a lot like fraud?

August 31, 2008 8:45 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Eric S: As long as you properly tag links between domains with utmLinker, you should be fine. It should bridge the gap between domains with the right cookie information.

Good luck!

September 2, 2008 3:24 PM

Mike said:

Hi Michael,

I am on the ROI GA Online training.

I have installed the Sleuth Tracking code, but I get "(not set)" when I go check the User Defined data.

I cannot spot what I am doing wrong.

You can view my code in the source of this page:

http://www.enquete-satisfaction.com/

Thanks for your help!
Mike

October 6, 2008 9:06 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Mike: The ga_keyword2.js file must go between the first <script> section of the Google Analytics Tracking Code and the second. You have it before. Please read the article again and be sure to place it in precisely the spot that I indicated. That should fix it for you.

You also should be wary of "smart" or curled quotes showing up in your code. If you use Microsoft Outlook or Word to edit code with quotation marks and paste it into your site, you might end up with a left or a right curled quote (“ or ”) instead of a standard quote ("). Be sure to only use standard quote marks in HTML code.

October 6, 2008 11:03 AM

Mike said:

Michael,

Could it be that I had copied the code from an older version of the article?

I am asking since my code also includes Sleuth() at the end, that the new code doesn't seem to include.

Thanks for your help!
Mike

October 8, 2008 9:52 AM

Eddy said:

This is a great script that I have been using flawlessly for a while now, but for the past month or so, all the keywords within the user defined page are still attached to the Google search query that is after the q variable as in http://www.google.co.uk/search?hl=en&q=keyword1+keyword2&meta=
I dont understand why this has started happening but could do with some advice.

thanks
eddy

October 8, 2008 11:43 AM

Eddy said:

Michael, if not done so already is it possible to add the search queries for the following Google search network partners?
aolsearch.aol.co.uk
www.winbuyer.co.uk
search.babylon.com
www.kellysearch.co.uk
business.shop.ebay.co.uk
search.virginmedia.com
www.hotfroguk.co.uk
uk.ask.com
www.tiscali.co.uk
search1.sky.com
search.mywebsearch.com

there are quite a few more but they generate just one or two visits.

regards
eddy

October 8, 2008 12:35 PM

art said:

Great script. Cant wait to see the results.

October 12, 2008 10:35 PM

Mike said:

Hi Michael,

I got the script to work. However, there are 2 issues:

1) About 20-25% of the visits show as "not set" (I don't use content for that campaign, only search with Google & Search Network).

Can you tell what they could account for?

2) It's a campaign with French keywords and the script doesn't capture the accents properly (whereas GA's Traffic Sources > Keyword Report does). E.g. the word "pr\xE9vention" shows as "prévention".

Is there a way to correct that?

Thanks!
Mike

October 13, 2008 8:04 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Mike: The reason why 20-25% of your visits are "not set" is because the script currently does not account for all of the engines that are a part of the Google search network. We've been working on an update for that, which should be released in the next few days, and should reduce the percentage of "not sets".

We'll also work on getting the accents fixed. Thanks for letting me know!

October 14, 2008 10:42 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Eddy: I'm not really sure what you mean by this. Can you illustrate with a screenshot or a URL?

October 14, 2008 10:45 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Eddy: I've been working on the script, trying to increase the number of search engine query parameters that it recognizes. Thanks for your list, and look for an update over the next few days.

October 14, 2008 10:46 AM

art said:

Great tool! I have started to see the results and they are amazing. 80% of my visits are showing as "not set". Are they all as a results of google parters not being included or because I haven't set utm_medium=ppc for both yahoo and msn ppc traffic? the interesting part is the bulk of our revenue is coming from google partners/or the other engines...the "not set" portion.

Second question..I want to add another domain which is an add-on to the main domain..Do I follow the exact steps for additional domains.

October 15, 2008 12:42 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Art: It could be because you haven't set utm_medium=cpc for Yahoo! and MSN paid traffic. Many Google partners aren't included yet, either, but I'll be posting an update to the script that will contain more of those partners. Keep an eye out on the blog, or subscribe to it to keep up-to-date.

October 15, 2008 10:26 AM

Clikckbank Affiliates said:

Thanks for the update...

October 20, 2008 3:14 PM

Moses Chang said:

Hi, just stumbled upon this tool and immediately created a new Google Analytics account for our website and installed it. Do I lose the ability to track AdWords Campaigns (under the Traffic Sources tab in Google Analytics) once this tool is installed? I also can't find where the search query info are being displayed...

Thanks in advance,
Moses

October 22, 2008 10:46 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Moses: This won't affect your AdWords Campaigns report and won't take away your ability to track campaigns, adgroups, or keywords. To access the exact keyword information, you can either drill down to a specific campaign/adgroup/keyword in the Traffic Sources > AdWords > AdWords Campaigns report and use the Dimension User Defined dropdown.

You can also view all of your exact keyword combinations using the Visitors > User Defined report.

October 22, 2008 11:01 AM

Aidin said:

How does this differ from the filter hack? Which one is better?

November 4, 2008 6:04 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Aidin: Check out my first article when I first created the script for how it differs from Omega's filter hack. I like the script better for the reasons outlined there.

November 5, 2008 1:32 PM

Gavin Doolan said:

Hi there,
I wonder if its possible to concatenate search queries to the user defined value to see data before the last click. (preventing a last click wins scenario)

What I mean is see the string of keywords used before a purchase. Say during the buyer research phase, till the point of purchase?

Obviously there is also the issue of previous campaigns which triggered a visit such as banner / email but I figured this may be the place to mention such an idea.

I've only just started to learn JS myself, perhaps by the time I'm finished reading my current book I'll have an idea on how to do it myself.

Cheers,
Gavin.

November 12, 2008 5:00 AM

Mike said:

Hello Michael,

Are you aware of this Advanced Filter setup that shows the bid keyword + exact search query?

http://www.ga-experts.com/blog/2006/11/how-to-get-detailed-ppc-keyword-data-from-google-analytics/

If so can you comment on the advantages/disadvantages of yours vs. theirs?

One thing that comes to mind is that theirs leaves the User Defined variable free for another utilization.

Thanks!
Mike

November 18, 2008 4:05 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Gavin: It's definitely possible. We've been working on something very similar here. Good luck on your own JS pursuits! Let us know if you post something about this elsewhere and we'll be sure to give you some link love.

November 19, 2008 3:11 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Mike: Definitely. It was Brian's filter that inspired me. The only issue I had with their is how it works on return visits to sites. See my original article for a full explanation.

November 19, 2008 3:13 PM

Aidin said:

Is there a way to implement this script to another profile?The first profile is already using the user defined field by live person chat. Could the two coexist within the same profile?

November 26, 2008 4:03 PM

Bud Gibson said:

How does this play with something like advanced segmentation? I was looking at those reports, and they seem to show what percentage of your search traffic for a given keyword is from paid sources.

The one thing I can see is that I might be able to see how my keywords are broad matching to actual search terms.

December 9, 2008 8:36 AM

Amit said:

Hi Michael,

Awesome post!
I was wondering if combining all the javascript in to a single .js file would be ok?

ON THE WEBPAGE YOUR WOULD PUT:

THE CONTENTS ON MyGA.js WOULD LOOK AS FOLLOWS:

var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));

function noPercent(x)
{
x = unescape(x);
return x.replace(/\+/g," ").replace(/^\s\s*/, '').replace(/\s\s*$/, '');
}

function getRef()
{
ref = document.referrer;
re = /(\?|&)(q|p|query|encquery|qt|terms|rdata|qs|wd|text|szukaj|k|searchExpr|
search_for|string|search_query|searchfor)=([^&]+)/;
searchq = re.exec(ref);
if(searchq) {
searchq[3] = noPercent(searchq[3]);
sleuthTracker._setVar(searchq[3]);
}
else {
sleuthTracker._setVar('Referral: ' + document.referrer);
}
}

function sleuth()
{
if(document.location.search.indexOf("gclid")!=-1||
document.location.search.indexOf("cpc")!=-1) {
getRef();
}
}

var sleuthTracker = _gat._getTracker("UA-1");
sleuthTracker._initData();
sleuth();

var pageTracker = _gat._getTracker("UA-XXXXXX-1");
pageTracker._initData();
pageTracker._trackPageview();

December 24, 2008 4:45 AM

Amit said:

no worries, I figured out why they need to be seperate. Thanks!

December 24, 2008 5:16 AM

rookie said:

The script works great!!
Can somebody help me to modify the script to append the ip of the user next to the search string? This would be invaluable for our statistical analysis. Unfortunately my javascript knowledge is limited. Thanks in advance!

January 4, 2009 6:22 PM

Bud Gibson said:

I just installed this script. An observation: why didn't you name space it? That would eliminate almost all possibilities of javascript conflict which I noticed one commenter remarking. I may do that myself if I get some spare time. It just involves encapsulating your functions in an object with a particular name. You then access the functions with Object.functionName().

January 7, 2009 10:37 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Amit: Yep, there's a reason why they're separate, though you can wrangle the JavaScript in such a way that there's only a single reference for all Google Analytics code, if you wanted to.

January 29, 2009 1:37 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@rookie: Glad the script is working for you!

As pulling IP addresses into Google Analytics actually violates the terms and conditions (and is impossible to do with JavaScript alone), there are currently no plans to add this functionality to the script.

January 29, 2009 1:43 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Bud: We have been testing a version of this script internally that expands on the features and uses object-oriented coding, but you're welcome to post your own.

January 29, 2009 1:50 PM

satin jain said:

but where i put this code..

i m new about this stuff...

please tell me where i have two put this script ...

please tell me...

February 13, 2009 2:55 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@satin jain: Just replace the exiting Google Analytics code, wherever it is on the page, with the one in the box.

February 13, 2009 3:17 PM

Brian Kaldenberg said:

I have installed everything and it appears to be tracking exact keywords correctly.

Problem is when inside analytics if I click the "clicks" tab, none of the clicks, impressions, ctr, cost, etc. data is showing up for dimension user-defined.

I have auto-link tag set to on.

Clicks data shows up for my broad match adgroup, but isn't the point of exact keyword tracking to be able to see clicks data for exact keywords within broad match?

I sure hope it is possible.

February 27, 2009 1:58 AM

Nikki said:

Hi

Is there a way of relating the keyword input to the keyword bid on? e.g. a hybrid of yours and Brian Cliftons PPC terms methods (his override bid term filter). So that a client can see e.g. car parking (car+parking+greater+manchester) using the ga2.js file?

Thanks
Nikki

March 16, 2009 8:54 AM

Richie Rich said:

Hi Michael. I have been successfully using the code here on 6 PPC accounts and the information has proved invaluable - thx so much for this.
However today on 2 of my 6 accounts I have no adwords data showing in my analytics? (and therefor no excat keyword tracking. Have you experienced this before - it may very well be an adwords glitch? Any ideas?

March 25, 2009 8:26 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Richie: No idea why it's not working. Have you checked to make sure that your AdWords linking and cost data is all set up properly?

March 25, 2009 3:20 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Nikki: It seems like it would be possible using filters. Give it a go and let us know how it works out.

March 25, 2009 3:24 PM

Medela Dude said:

Hi Mike, appreciate your work on this and have been using it for a year or 2 now.

Any news on a resolution to the "Not Set" issue?

May 6, 2009 10:51 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Medela Dude: Not yet. There's just a lot of traffic from Google that doesn't match the standard query. We'll definitely keep everyone posted with any updates to the code. Be sure to add the ROI blog to your reader of choice or subscribe via email with the link at the top right.

May 6, 2009 2:27 PM

Salman said:

I have implemented the script. Works fine. It returns the actual KWs in the user defined reports, however there is no goal conversions associated with these KWs although i know that i have made conversions through these KWs.

May 15, 2009 12:17 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Salman: Try drilling down to the keyword level in the Keywords report where you should see your conversions. Then segment by User Defined. What do you see?

May 15, 2009 9:57 AM

Neal said:

Michael, does this keyword filter affect GA ecommerce data? I recently installed it in one of my sites...I see the specific queries from Adwords but don't see conversion data. Our overall ecommerce stats also show $0 revenue right after installing the GA code.

June 19, 2009 7:39 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Neal: It shouldn't affect ecommerce data. What happens when you remove it?

June 22, 2009 11:53 AM

Neal said:

Michael,

We installed the code and all ecommerce data stopped reporting. We were averaging several $30,000 in revenue per day and then it went to $0 after we changed the GA code. Any ideas?

June 24, 2009 9:57 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Neal: Have you tried using the Exact Keyword Tracking script on all pages but your receipt page?

June 25, 2009 4:58 PM

Vince said:

Can someone explain how we can embed this data into our Website forms so the search keywords and PPC data is added to our leads please?

Basically, trying to achieve the same as what Salesforce.com Google adwords integration has with their web-to-lead form.
http://www.semgeek.com/semgeek/2008/03/what-you-need-t.html

July 18, 2009 9:49 AM

neal@akamaiseo.com said:


Michael, are you saying that the modified GA script needs to be on every page of your site except for your confirmation/receipt page?

July 20, 2009 3:51 PM

afzal hanif said:

Really great post, thanx. Right now i'm using the alternate 'filter method' to show the true keywords, however, conversions are still only attributed to the original (adwords) keyword. Perhaps I overlooked, but will this javascript method also show conversions to the true keywords? Hope you can help me, thanx:)

August 6, 2009 3:55 AM

afzal hanif said:

Nice post. I have been using the alternate mode now for a while, but one issue with this: conversions are not attributed to the 'true keywords', but to the keyword defined in adwords. Will this method show actual conversions to the true keywords? Perhaps I missed it but thanx in advance:)!

August 11, 2009 10:44 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Afzal: Yes, it will. One benefit it has over the other method. Just be sure to use the user defined report.

August 19, 2009 10:22 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Neal: Technically it should be on every possible landing page. You can write conditional JavaScript to check and see whether or not this is this case, or you can just put it on every page. Either way works, really.

August 19, 2009 10:32 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Vince: That's a bit more complicated. Justin Cutroni has detailed a method for something similar at his blog. Hope it helps!

August 19, 2009 10:36 AM

Jen said:

thanks Michael and ROIRev. This one gave us substantial savings over a twelve month period.

September 4, 2009 4:51 AM

Guy said:

Great stuff!!
Any way to fix it to show utf-8 keywords?

October 9, 2009 11:26 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Guy: To be honest, I haven't spent a lot of time working on the script. If you'd like to add decoding for utf-8, please feel free! Just let us know of any updates so we can share the wealth.

October 9, 2009 1:24 PM

Riedel Wine Glass said:

So should this script be on every page in the website? sorry newbie question

December 22, 2009 3:18 PM

Wytze said:

Thanks a million Michael,

Your script has made our year! Like somebody else mentioned earlier. This information is invaluable! Only running for a couple of days and I've already seen so many incorrect queries!

I do have a question though, is there a way to associate costs to the queries like you see with Search Query reports in Adwords?

Thanks again so much and have an early merry christmas! :)

December 23, 2009 7:00 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Riedel: Yes, put it on every page of your site. It should replace the standard Google Analytics Tracking Code.

January 4, 2010 5:55 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Wytze: No, there's not currently a way to associate costs with the queries. We typically just use the SQR in AdWords to do that.

January 4, 2010 5:57 PM

David Ogletree said:

I used to work at a ppc agency and our Google rep gave me a filter that let me track search partners. I did not save the filter and I don't have access to that account anymore. I can't seem to find how to do this again. Can you make a filter that does this?

January 12, 2010 9:46 AM

GregBB said:

What would be the reasons to favor the ga.js update to view actual search phrases in comparison to applying the "Override Bid Term" filters? Is the result the same? One obvious reason is that you can instantly apply it to all profiles, which could also be a disincentive if you would like to have more flexibility. Would appreciate your thoughts. Thanks!

February 4, 2010 8:01 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@David: You can add a query parameter to your destination URLs and then use the special AdWords macro {placement} to insert the URL that the ad was displayed on, like so:

www.mysite.com?site={placement}

Then you can use something like Filters, Site Search or Custom Variables to pull that data out and put it into a Google Analytics report.

March 6, 2010 4:18 PM

Kevin Joyner said:

Hi Michael

I seem to have gathered the impression from somewhere that there are plans ultimately to deprecate the GA user defined variable, and that we should use custom variables where possible.

Would it be worthwhile to adapt your Keyword Sleuth script to use custom variables? If so, I don't suppose you've done that, have you? :-)

Many thanks

Kevin

April 20, 2010 9:00 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Kevin: We have, and it works just fine. Look for an article about it in the near future.

April 20, 2010 11:10 AM

Sandra said:

Ok...pardon the moron. I have read this entire thread and just want to make sure I understand completely b4 I implement the code.

1. I literally just REPLACE the code on my sites with the one up top u provide (obviously changing the profile numbers)?

2. Do I have to also upload this ga_keyword2.js file? If so, why?

Thanks so much - really looking 4ward to taking it for a test drive!

S

May 19, 2010 3:55 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Sandra: Yes, replace the code on your site with the one above. And, yes, you do need to upload the file. Why? Because that's where all the code that grabs the search query is.

May 25, 2010 9:42 AM

Eric said:

Hi Michael,

I wanted to thank you for this wonderful tool. We've been using it for almost 2 years and its benefit has been significant.

Yesterday, I upgraded my site to the new asynchronous GATC code but wasn't quite sure how to integrate ga_keyword.js so I took my best shot as shown below. No luck--the user defined value data has disappeared.

Actually, there are two problems here. Whenever I originally set up the 'traditional' GATC code with the two additional lines for cross-domain tracking, the UDV info would disappeared. We decided knowing what the original queries were outweighed cross domain tracking so we just left out the

pageTracker._setDomainName('none');
pageTracker._setAllowLinker(true);

lines and lived with the compromise. This time I included the asynchronous equivalent for cross domain hoping it would work but no luck.

_gaq.push(['_setDomainName', 'none']);
_gaq.push(['_setAllowLinker', true]);

So I've changed too many variables to know what the real problem is, but if this is a no-brainer for you, would you please point out my error. Alternately, I can go back and remove the cross domain asynchronous lines to try and isolate the cause and effect and see what happens.

Also noticed an early post about deprecating the _setVar() function and an upcoming post about that? Perhaps that post might be nearby?

Would be grateful for any help.

Eric.

Current Attempt:

<!--
<head>

<script src="ga_keyword.js" type="text/javascript"></script>

<script type="text/javascript">

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-123456-1']);

_gaq.push(['_setDomainName', 'none']);
_gaq.push(['_setAllowLinker', true]);

_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

</script>

</head>
-->

July 7, 2010 9:00 AM

Darrell said:

Google Adwords lets me generate a report of keyphrases typed that caused ads to show up and wheter they generated clicks or not. These are phrases typed during the search, including searches on other sites, not just the keyword that match the ad. I can then see phrases generating clicks that I don't like the words that are in them, then ad those to my negative keywords. Is this something new that was not available in 2008 when this ga_keyword script was created?

September 8, 2010 5:52 PM

George Strait Tickets said:

Then you can use something like Filters, Site Search or Custom Variables to pull that data out and put it into a Google Analytics report.

September 23, 2010 5:58 AM

Christina said:

I used to work at a ppc agency and our Google rep gave me a filter that let me track search partners. I did not save the filter and I don't have access to that account anymore. I can't seem to find how to do this again. Can you make a filter that does this

October 26, 2010 8:58 AM

PPC Whiz said:

This stuff is great! Keep up the good work team, I really appreciate you sharing this with the community. You are an excellent resource for us PPC guys out there looking to maximize our spend.
My clients will thank you!

February 14, 2008 3:25 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@PPC Whiz: Glad we could help out! Definitely keep posted here on any additions or updates, and like I said in my post, our own team will be posting some of their tips and tricks in the coming weeks.

February 14, 2008 4:22 PM

Jesse DaCosta said:

Hey Michael,

Thanks for the update, have been on the lookout for it! I've tried another method from another blog but that doesn't seem to work, at least for me, so now I've updated to the new code I'm going to test this out.

Thanks again!

February 14, 2008 4:37 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Jesse: Great! Let me know how it works for you. We're always trying to improve it.

February 14, 2008 5:54 PM

Christian Martin said:

Thanks for updating the ga.js script with this! I only saw the original change for the old urchin code yesterday after your webinar. I've already changed the GA code on both our site and looking forward to seeing the results in the coming days.

I do have a question... In the Traffic Sources::Keywords section, their are toggles for Show: total | paid | non-paid and then the Segment listbox.

On first glance, it would seem GA is providing everything without the script. Am I being simplistic in my cursory look?

Thanks again!

February 14, 2008 7:06 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Christian: Unfortunately, the Keywords report will only show you the bid terms for your paid search. Basically, it will show you the keyword phrase that you bid upon, but not the one that visitors actually typed into the search engine. Hope that makes sense.

February 15, 2008 9:32 AM

Dave Cardwell said:

Thanks for updating this script and sharing it with the community.

I'm curious - why the "UA-1" in this line of the script:
_gat._getTracker("UA-1");

February 15, 2008 11:51 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Dave: It's just a precaution, due to the way that setVar operates, and we've found that it leads to more accurate usage stats.

February 15, 2008 1:57 PM

Searchquant said:

Doesn't it seem strange that Google wouldn't make this a feature in G Analytics early on? It's clear any smart marketer's gonna want to know which queries within phrase or broad matched keywords are working and not working.

Google gets 70% of its revenue from phrase and broad match.

February 15, 2008 4:53 PM

Sonja Bakker said:

Hi,

This quiet cool. I already saw that the previous script wasn't working anymore. Going to try this one now!

February 18, 2008 11:27 AM

Julien Raby said:

Hi Michael,

thanks a lot for this new version of the script, I was using the old filter hacks but it doesn't work anymore...

One question: the script as it is now doesn't seem to work if I manually tag my link (I almost always tag my links instead of using the auto-tagging to gain more control over the utm_campaign variable...) so I was wondering if there were a quick fix fo manual link tagger like myself?

Thanks again,
Julien

February 19, 2008 6:54 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Julien: While we definitely don't recommend that you manually tag AdWords ads (it causes problems when Analytics links up the data between your two accounts), this method should work for manually tagged links, so long as those links are tagged with utm_medium=cpc and the visits are coming from a search engine with a plainly visible search query in the URL (e.g., q=search+query, p=search+query, query=search+query).

February 22, 2008 3:28 PM

Chris Bradley said:

Thanks for this, I just tried the other method last week and didn't get it to work so this comes at a great time for me but I do have one question..

Should I upload the script to my root directory?

February 24, 2008 2:41 PM

Shawn Purtell, Senior Web Analytics Engineer Author Profile Page said:

@Chris:

You can upload the file wherever you like. Most websites have a specific place where scripts are stored, but it's different for everybody. The important thing is to make sure the call to the .js script is pointing to the right place.

February 25, 2008 9:29 AM

Charles Meaden said:

The actual ga_keyword2.js script contains the following lines


var pageTracker = _gat._getTracker("UA-XXXXXX-X");

The page says not to edit the script, but should I be changing the [yoursitehere] and UA-XXXX lines so that they correspond to our tracking codes?

March 17, 2008 10:40 AM

Jeremy Aube, Director of Engineering Author Profile Page said:

@Charles: Those lines are just a re-iteration of the installation instructions as given in the article. They are just comments, so you don't need to change it.

March 18, 2008 10:48 AM

Charles Meaden said:

Jeremy,

Thank you. Two more questions if I may.

1. Does it make any difference if I have amended the code to use our details
2. Can I use remove the commented section from the ga_keyword2.js file then

March 19, 2008 6:55 AM

Jeremy Aube, Director of Engineering Author Profile Page said:

@Charles: You really shouldn't be making any changes to the javascript file. If you're just making changes to or removing the comment section, that won't affect the functionality of the script, but it would be best to leave it as is. Then anyone who looks at the script will have the version number, author, general instructions (rather than specific to a single site's setup), and when it was last modified. Any changes to the script itself could negatively affect its functionality. Michael has written this script very precisely so that it needs no modification to work with your site.

March 19, 2008 9:52 AM

Ron said:

ok, I really want to get this data from my analytics and I have upgraded to ga and installed the tracking code...but I can't for the life of me understand where I find the detailed keyword search data in my analytics account. Can someone point me in the right direction?

April 2, 2008 4:21 PM

Jeremy Aube, Director of Engineering Author Profile Page said:

@Ron: The Exact Keyword Data for the site will be in the User Defined Report. You can also segment various reports by the User Defined Variable to see this information for specific visitor traffic segments. See Michael's previous post for more information.

April 2, 2008 4:39 PM

Ron said:

So if I look in the tab "Visitor/UserDefined" and all I see under the user defined values is "not set" then it's safe to assume I screwed up in inserting the tracking code?

April 2, 2008 5:35 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Ron: Well, it either means that you screwed up, or that you don't have any paid search traffic coming into your site. The traffic has to be auto-tagged AdWords clicks or manually tagged clicks with utm_medium=cpc.

Good luck!

April 3, 2008 10:59 AM

Ryan said:

Okay, I feel like an idiot.

The code checks out fine. Analytics is otherwise tracking fine. And I am getting my adwords PPC traffic to come up.

But STILL, I'm only getting "not set".

Is there something I'm missing? Maybe something obscenely obvious?

Thanks so much!

June 3, 2008 10:06 AM

Ryan said:

Yup. I'm definitely an idiot.

1. Didn't change the .js src path.

2. Didn't upload the .js file.

June 3, 2008 10:34 AM

Eric said:

Thanks for making these scripts. I put them on my site about a week ago, and the info has been very valuable.

Unfortunately, about 50% of the data comes back as (not set) and a slightly better return of only 33% on Yahoo. I don't have my account autotagged for various reasons, but every keyword has it's own URL with utm_medium=cpc. Is this the normal capture for the script or perhaps I have done something wrong or does the order of the utm_ variables in the search string matter. Currently I set the source, medium, campaign and then the term.

Thanks again for this wonderful tool.

June 10, 2008 2:36 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Eric: Well, content network will never display a search query, and some of the search partner sites don't format the search query in the same way that Google does. 50% is about the norm for what I see.

If you can find the search network sites that your ads are running and provide them, I may be able to expand the script to use their search queries.

June 10, 2008 4:27 PM

Daniel Waisberg said:

Hi Michael,

Thank you very much for the feature it is wonderful.

I was wondering if this code can work together with the one created by John Henson from LunaMetrics: Stuff More Than One Value into GA\x92s User Defined Segment . If so, this would solve the issue of using other User Defined Variables together with it.

Thank you again.

June 22, 2008 4:05 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Daniel: I don't see why the two scripts wouldn't play nice together. :) It may require some modifications to the JavaScript. Give it a shot and let us know how it works out.

June 24, 2008 8:24 AM

Eran Malloch said:

Hi Michael,

I REALLY REALLY REALLY need this tool to work (great idea and thanks to all who developed it), but unfortunately, whenever I add it to a site created by our webdesign partners, it somehow interferes with the script that creates their drop-down menu system, and the menu system stops working... :(

This has happened on 2 seperate sites now, and obviously we have to remove your script because a non-working menu system just aint gonna cut it. ;)

I'm guessing if this is happening to me, there are probably others it is happening to as well, but perhaps they haven't bothered to contact you and mention it.

ANY help you (or anyone else reading this comment) can provide with this issue would be GREATLY appreciated. I am happy to email you the offending site urls, etc.

Thanks in advance for your time, and I really do appreciate your efforts to provide this vital tool (and bah humbug to Google for NOT providing it) ;)


Eran Malloch
WCR Internet Marketing
Perth, Western Australia

July 11, 2008 2:22 AM

wil said:

How do I create a report that shows side-by-side the keyword in the AdWords campaign that was triggered along with the user defined variable (the search term). Right now, under traffic sources, I can see one or the other.

Thanks,

Wil

July 12, 2008 2:27 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Eran: I'd check to make sure that none of the functions from the menu system interfere with the keyword script. Beyond that, I don't see why it would cause any problems. Because of the sheer number of setups and JavaScript present on websites, there's no possible way we can troubleshoot each individual issue with the script, but if you have any additional comments on precisely what is going on (error messages, etc.), then maybe we can help out.

July 21, 2008 1:29 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Wil: There is no such report, but you could create a new profile with an Advanced Filter that plugs the User Defined field into the Campaign Term field. Just cram 'em both together, and that way when you look at your keywords list, you would see:

"bid term (search term)"

This will mean that cost and click data for your AdWords Campaigns keyword report will not match up properly, thus the reason why I recommend creating an additional profile.

Hope that helps.

July 21, 2008 1:36 PM

Eric Werner said:

Hi and thanks! One quick question, what does this do?

pageTracker._initData();

This line isn't in the code that Google gave me and you didn't mention anything about it in the post so I wanted to check.

Thanks!

August 8, 2008 12:18 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Eric: pageTracker._initData() is a deprecated function that was previously required before running the Google Analytics pageTracker. You can get rid of it or keep it in; entirely up to you.

August 8, 2008 1:52 PM

Jason said:

Michael - I've modified a function in the ga_keyword2.js code that I find quite useful re: more accurate stats gathering:

function noPercent(x)
{
x = unescape(x);
x = x.replace(/\+/g," ").replace(/^\s\s*/, '').replace(/\s\s*$/, '');
return x.toLowerCase(); // added feature
}


this basically groups all upper & lower case variations so that I get an accurate picture of the number of people using a particular word or phrase. Great script!

August 14, 2008 9:44 PM

Ricky said:

I think that this script looks great, and I have just updated the script on our site to check it out.

Though one question still remains, how does this differ from the report you get out of Adwords that shows you which search results that triggered your adwords to show and generate a click?

Thanks!

August 19, 2008 8:14 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Ricky: Check out my co-worker Mark Curtis' article on the Keyword Sleuth script versus the AdWords Search Query Performance Report for the answer to your question.

August 19, 2008 10:17 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Jason: Thanks for the info. You could also use a lowercase filter inside of Google Analytics if you don't want to modify the code (if, for instance, it's already installed on your site).

August 19, 2008 10:19 AM

Eric S said:

Michael, thanks again for this wonderful script. I recently upgraded to the new tracking code and the script worked fine. Unfortunately, my 'check-out' is handled by a third party that is still running the legacy script and they are hesitant to upgrade. Note that their legacy script also has

_udn="none";
_ulink=1;

in the legacy code to enable cross-domain tracking.

So, I downgraded back to the legacy code and added the two lines for cross-domain tracking code that I had not used before, and the next day all of my User Defined Value data was missing. So I deleted the

_udn="none";
_ulink=1;

lines and it immediately returned but this left me without the cross domain tracking I had hoped to gain. Note that the User Defined Value came through just fine in the ga.js version except the link was broken across the domains due to code incompatability. Any suggestions for getting the legacy version to work cross-domain. I noticed that the slueth(); function was in the legacy code on your first blog in 07 but not the more recent blog. Might this be part of it?

On a completely separate issue, I appended the cpc search term that actually responded to the original user query to the UDV and was stunned at the level of mismatch. For example, I had a phrase/exact match bid for "word1 word2 word3 word4", the user queried the exact term "word1 word2 word3 word4" but Google responded to the query with a broad matched term "word1 word2 wordX" where wordX was barely a synonym but the price point was much higher--not to mention the ad displayed to the user's query was far less relevant because the reponse came from a different ad group. Google does this a lot.

Do you see this mis-matching to increase Search Engine revenues a lot and does your consulting service offer methods of combating this problem of what seems a lot like fraud?

August 31, 2008 8:45 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Eric S: As long as you properly tag links between domains with utmLinker, you should be fine. It should bridge the gap between domains with the right cookie information.

Good luck!

September 2, 2008 3:24 PM

Mike said:

Hi Michael,

I am on the ROI GA Online training.

I have installed the Sleuth Tracking code, but I get "(not set)" when I go check the User Defined data.

I cannot spot what I am doing wrong.

You can view my code in the source of this page:

http://www.enquete-satisfaction.com/

Thanks for your help!
Mike

October 6, 2008 9:06 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Mike: The ga_keyword2.js file must go between the first <script> section of the Google Analytics Tracking Code and the second. You have it before. Please read the article again and be sure to place it in precisely the spot that I indicated. That should fix it for you.

You also should be wary of "smart" or curled quotes showing up in your code. If you use Microsoft Outlook or Word to edit code with quotation marks and paste it into your site, you might end up with a left or a right curled quote (“ or ”) instead of a standard quote ("). Be sure to only use standard quote marks in HTML code.

October 6, 2008 11:03 AM

Mike said:

Michael,

Could it be that I had copied the code from an older version of the article?

I am asking since my code also includes Sleuth() at the end, that the new code doesn't seem to include.

Thanks for your help!
Mike

October 8, 2008 9:52 AM

Eddy said:

This is a great script that I have been using flawlessly for a while now, but for the past month or so, all the keywords within the user defined page are still attached to the Google search query that is after the q variable as in http://www.google.co.uk/search?hl=en&q=keyword1+keyword2&meta=
I dont understand why this has started happening but could do with some advice.

thanks
eddy

October 8, 2008 11:43 AM

Eddy said:

Michael, if not done so already is it possible to add the search queries for the following Google search network partners?
aolsearch.aol.co.uk
www.winbuyer.co.uk
search.babylon.com
www.kellysearch.co.uk
business.shop.ebay.co.uk
search.virginmedia.com
www.hotfroguk.co.uk
uk.ask.com
www.tiscali.co.uk
search1.sky.com
search.mywebsearch.com

there are quite a few more but they generate just one or two visits.

regards
eddy

October 8, 2008 12:35 PM

art said:

Great script. Cant wait to see the results.

October 12, 2008 10:35 PM

Mike said:

Hi Michael,

I got the script to work. However, there are 2 issues:

1) About 20-25% of the visits show as "not set" (I don't use content for that campaign, only search with Google & Search Network).

Can you tell what they could account for?

2) It's a campaign with French keywords and the script doesn't capture the accents properly (whereas GA's Traffic Sources > Keyword Report does). E.g. the word "pr\xE9vention" shows as "prévention".

Is there a way to correct that?

Thanks!
Mike

October 13, 2008 8:04 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Mike: The reason why 20-25% of your visits are "not set" is because the script currently does not account for all of the engines that are a part of the Google search network. We've been working on an update for that, which should be released in the next few days, and should reduce the percentage of "not sets".

We'll also work on getting the accents fixed. Thanks for letting me know!

October 14, 2008 10:42 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Eddy: I'm not really sure what you mean by this. Can you illustrate with a screenshot or a URL?

October 14, 2008 10:45 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Eddy: I've been working on the script, trying to increase the number of search engine query parameters that it recognizes. Thanks for your list, and look for an update over the next few days.

October 14, 2008 10:46 AM

art said:

Great tool! I have started to see the results and they are amazing. 80% of my visits are showing as "not set". Are they all as a results of google parters not being included or because I haven't set utm_medium=ppc for both yahoo and msn ppc traffic? the interesting part is the bulk of our revenue is coming from google partners/or the other engines...the "not set" portion.

Second question..I want to add another domain which is an add-on to the main domain..Do I follow the exact steps for additional domains.

October 15, 2008 12:42 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Art: It could be because you haven't set utm_medium=cpc for Yahoo! and MSN paid traffic. Many Google partners aren't included yet, either, but I'll be posting an update to the script that will contain more of those partners. Keep an eye out on the blog, or subscribe to it to keep up-to-date.

October 15, 2008 10:26 AM

Clikckbank Affiliates said:

Thanks for the update...

October 20, 2008 3:14 PM

Moses Chang said:

Hi, just stumbled upon this tool and immediately created a new Google Analytics account for our website and installed it. Do I lose the ability to track AdWords Campaigns (under the Traffic Sources tab in Google Analytics) once this tool is installed? I also can't find where the search query info are being displayed...

Thanks in advance,
Moses

October 22, 2008 10:46 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Moses: This won't affect your AdWords Campaigns report and won't take away your ability to track campaigns, adgroups, or keywords. To access the exact keyword information, you can either drill down to a specific campaign/adgroup/keyword in the Traffic Sources > AdWords > AdWords Campaigns report and use the Dimension User Defined dropdown.

You can also view all of your exact keyword combinations using the Visitors > User Defined report.

October 22, 2008 11:01 AM

Aidin said:

How does this differ from the filter hack? Which one is better?

November 4, 2008 6:04 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Aidin: Check out my first article when I first created the script for how it differs from Omega's filter hack. I like the script better for the reasons outlined there.

November 5, 2008 1:32 PM

Gavin Doolan said:

Hi there,
I wonder if its possible to concatenate search queries to the user defined value to see data before the last click. (preventing a last click wins scenario)

What I mean is see the string of keywords used before a purchase. Say during the buyer research phase, till the point of purchase?

Obviously there is also the issue of previous campaigns which triggered a visit such as banner / email but I figured this may be the place to mention such an idea.

I've only just started to learn JS myself, perhaps by the time I'm finished reading my current book I'll have an idea on how to do it myself.

Cheers,
Gavin.

November 12, 2008 5:00 AM

Mike said:

Hello Michael,

Are you aware of this Advanced Filter setup that shows the bid keyword + exact search query?

http://www.ga-experts.com/blog/2006/11/how-to-get-detailed-ppc-keyword-data-from-google-analytics/

If so can you comment on the advantages/disadvantages of yours vs. theirs?

One thing that comes to mind is that theirs leaves the User Defined variable free for another utilization.

Thanks!
Mike

November 18, 2008 4:05 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Gavin: It's definitely possible. We've been working on something very similar here. Good luck on your own JS pursuits! Let us know if you post something about this elsewhere and we'll be sure to give you some link love.

November 19, 2008 3:11 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Mike: Definitely. It was Brian's filter that inspired me. The only issue I had with their is how it works on return visits to sites. See my original article for a full explanation.

November 19, 2008 3:13 PM

Aidin said:

Is there a way to implement this script to another profile?The first profile is already using the user defined field by live person chat. Could the two coexist within the same profile?

November 26, 2008 4:03 PM

Bud Gibson said:

How does this play with something like advanced segmentation? I was looking at those reports, and they seem to show what percentage of your search traffic for a given keyword is from paid sources.

The one thing I can see is that I might be able to see how my keywords are broad matching to actual search terms.

December 9, 2008 8:36 AM

Amit said:

Hi Michael,

Awesome post!
I was wondering if combining all the javascript in to a single .js file would be ok?

ON THE WEBPAGE YOUR WOULD PUT:

THE CONTENTS ON MyGA.js WOULD LOOK AS FOLLOWS:

var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));

function noPercent(x)
{
x = unescape(x);
return x.replace(/\+/g," ").replace(/^\s\s*/, '').replace(/\s\s*$/, '');
}

function getRef()
{
ref = document.referrer;
re = /(\?|&)(q|p|query|encquery|qt|terms|rdata|qs|wd|text|szukaj|k|searchExpr|
search_for|string|search_query|searchfor)=([^&]+)/;
searchq = re.exec(ref);
if(searchq) {
searchq[3] = noPercent(searchq[3]);
sleuthTracker._setVar(searchq[3]);
}
else {
sleuthTracker._setVar('Referral: ' + document.referrer);
}
}

function sleuth()
{
if(document.location.search.indexOf("gclid")!=-1||
document.location.search.indexOf("cpc")!=-1) {
getRef();
}
}

var sleuthTracker = _gat._getTracker("UA-1");
sleuthTracker._initData();
sleuth();

var pageTracker = _gat._getTracker("UA-XXXXXX-1");
pageTracker._initData();
pageTracker._trackPageview();

December 24, 2008 4:45 AM

Amit said:

no worries, I figured out why they need to be seperate. Thanks!

December 24, 2008 5:16 AM

rookie said:

The script works great!!
Can somebody help me to modify the script to append the ip of the user next to the search string? This would be invaluable for our statistical analysis. Unfortunately my javascript knowledge is limited. Thanks in advance!

January 4, 2009 6:22 PM

Bud Gibson said:

I just installed this script. An observation: why didn't you name space it? That would eliminate almost all possibilities of javascript conflict which I noticed one commenter remarking. I may do that myself if I get some spare time. It just involves encapsulating your functions in an object with a particular name. You then access the functions with Object.functionName().

January 7, 2009 10:37 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Amit: Yep, there's a reason why they're separate, though you can wrangle the JavaScript in such a way that there's only a single reference for all Google Analytics code, if you wanted to.

January 29, 2009 1:37 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@rookie: Glad the script is working for you!

As pulling IP addresses into Google Analytics actually violates the terms and conditions (and is impossible to do with JavaScript alone), there are currently no plans to add this functionality to the script.

January 29, 2009 1:43 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Bud: We have been testing a version of this script internally that expands on the features and uses object-oriented coding, but you're welcome to post your own.

January 29, 2009 1:50 PM

satin jain said:

but where i put this code..

i m new about this stuff...

please tell me where i have two put this script ...

please tell me...

February 13, 2009 2:55 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@satin jain: Just replace the exiting Google Analytics code, wherever it is on the page, with the one in the box.

February 13, 2009 3:17 PM

Brian Kaldenberg said:

I have installed everything and it appears to be tracking exact keywords correctly.

Problem is when inside analytics if I click the "clicks" tab, none of the clicks, impressions, ctr, cost, etc. data is showing up for dimension user-defined.

I have auto-link tag set to on.

Clicks data shows up for my broad match adgroup, but isn't the point of exact keyword tracking to be able to see clicks data for exact keywords within broad match?

I sure hope it is possible.

February 27, 2009 1:58 AM

Nikki said:

Hi

Is there a way of relating the keyword input to the keyword bid on? e.g. a hybrid of yours and Brian Cliftons PPC terms methods (his override bid term filter). So that a client can see e.g. car parking (car+parking+greater+manchester) using the ga2.js file?

Thanks
Nikki

March 16, 2009 8:54 AM

Richie Rich said:

Hi Michael. I have been successfully using the code here on 6 PPC accounts and the information has proved invaluable - thx so much for this.
However today on 2 of my 6 accounts I have no adwords data showing in my analytics? (and therefor no excat keyword tracking. Have you experienced this before - it may very well be an adwords glitch? Any ideas?

March 25, 2009 8:26 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Richie: No idea why it's not working. Have you checked to make sure that your AdWords linking and cost data is all set up properly?

March 25, 2009 3:20 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Nikki: It seems like it would be possible using filters. Give it a go and let us know how it works out.

March 25, 2009 3:24 PM

Medela Dude said:

Hi Mike, appreciate your work on this and have been using it for a year or 2 now.

Any news on a resolution to the "Not Set" issue?

May 6, 2009 10:51 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Medela Dude: Not yet. There's just a lot of traffic from Google that doesn't match the standard query. We'll definitely keep everyone posted with any updates to the code. Be sure to add the ROI blog to your reader of choice or subscribe via email with the link at the top right.

May 6, 2009 2:27 PM

Salman said:

I have implemented the script. Works fine. It returns the actual KWs in the user defined reports, however there is no goal conversions associated with these KWs although i know that i have made conversions through these KWs.

May 15, 2009 12:17 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Salman: Try drilling down to the keyword level in the Keywords report where you should see your conversions. Then segment by User Defined. What do you see?

May 15, 2009 9:57 AM

Neal said:

Michael, does this keyword filter affect GA ecommerce data? I recently installed it in one of my sites...I see the specific queries from Adwords but don't see conversion data. Our overall ecommerce stats also show $0 revenue right after installing the GA code.

June 19, 2009 7:39 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Neal: It shouldn't affect ecommerce data. What happens when you remove it?

June 22, 2009 11:53 AM

Neal said:

Michael,

We installed the code and all ecommerce data stopped reporting. We were averaging several $30,000 in revenue per day and then it went to $0 after we changed the GA code. Any ideas?

June 24, 2009 9:57 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Neal: Have you tried using the Exact Keyword Tracking script on all pages but your receipt page?

June 25, 2009 4:58 PM

Vince said:

Can someone explain how we can embed this data into our Website forms so the search keywords and PPC data is added to our leads please?

Basically, trying to achieve the same as what Salesforce.com Google adwords integration has with their web-to-lead form.
http://www.semgeek.com/semgeek/2008/03/what-you-need-t.html

July 18, 2009 9:49 AM

neal@akamaiseo.com said:


Michael, are you saying that the modified GA script needs to be on every page of your site except for your confirmation/receipt page?

July 20, 2009 3:51 PM

afzal hanif said:

Really great post, thanx. Right now i'm using the alternate 'filter method' to show the true keywords, however, conversions are still only attributed to the original (adwords) keyword. Perhaps I overlooked, but will this javascript method also show conversions to the true keywords? Hope you can help me, thanx:)

August 6, 2009 3:55 AM

afzal hanif said:

Nice post. I have been using the alternate mode now for a while, but one issue with this: conversions are not attributed to the 'true keywords', but to the keyword defined in adwords. Will this method show actual conversions to the true keywords? Perhaps I missed it but thanx in advance:)!

August 11, 2009 10:44 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Afzal: Yes, it will. One benefit it has over the other method. Just be sure to use the user defined report.

August 19, 2009 10:22 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Neal: Technically it should be on every possible landing page. You can write conditional JavaScript to check and see whether or not this is this case, or you can just put it on every page. Either way works, really.

August 19, 2009 10:32 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Vince: That's a bit more complicated. Justin Cutroni has detailed a method for something similar at his blog. Hope it helps!

August 19, 2009 10:36 AM

Jen said:

thanks Michael and ROIRev. This one gave us substantial savings over a twelve month period.

September 4, 2009 4:51 AM

Guy said:

Great stuff!!
Any way to fix it to show utf-8 keywords?

October 9, 2009 11:26 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Guy: To be honest, I haven't spent a lot of time working on the script. If you'd like to add decoding for utf-8, please feel free! Just let us know of any updates so we can share the wealth.

October 9, 2009 1:24 PM

Riedel Wine Glass said:

So should this script be on every page in the website? sorry newbie question

December 22, 2009 3:18 PM

Wytze said:

Thanks a million Michael,

Your script has made our year! Like somebody else mentioned earlier. This information is invaluable! Only running for a couple of days and I've already seen so many incorrect queries!

I do have a question though, is there a way to associate costs to the queries like you see with Search Query reports in Adwords?

Thanks again so much and have an early merry christmas! :)

December 23, 2009 7:00 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Riedel: Yes, put it on every page of your site. It should replace the standard Google Analytics Tracking Code.

January 4, 2010 5:55 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Wytze: No, there's not currently a way to associate costs with the queries. We typically just use the SQR in AdWords to do that.

January 4, 2010 5:57 PM

David Ogletree said:

I used to work at a ppc agency and our Google rep gave me a filter that let me track search partners. I did not save the filter and I don't have access to that account anymore. I can't seem to find how to do this again. Can you make a filter that does this?

January 12, 2010 9:46 AM

GregBB said:

What would be the reasons to favor the ga.js update to view actual search phrases in comparison to applying the "Override Bid Term" filters? Is the result the same? One obvious reason is that you can instantly apply it to all profiles, which could also be a disincentive if you would like to have more flexibility. Would appreciate your thoughts. Thanks!

February 4, 2010 8:01 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@David: You can add a query parameter to your destination URLs and then use the special AdWords macro {placement} to insert the URL that the ad was displayed on, like so:

www.mysite.com?site={placement}

Then you can use something like Filters, Site Search or Custom Variables to pull that data out and put it into a Google Analytics report.

March 6, 2010 4:18 PM

Kevin Joyner said:

Hi Michael

I seem to have gathered the impression from somewhere that there are plans ultimately to deprecate the GA user defined variable, and that we should use custom variables where possible.

Would it be worthwhile to adapt your Keyword Sleuth script to use custom variables? If so, I don't suppose you've done that, have you? :-)

Many thanks

Kevin

April 20, 2010 9:00 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Kevin: We have, and it works just fine. Look for an article about it in the near future.

April 20, 2010 11:10 AM

Sandra said:

Ok...pardon the moron. I have read this entire thread and just want to make sure I understand completely b4 I implement the code.

1. I literally just REPLACE the code on my sites with the one up top u provide (obviously changing the profile numbers)?

2. Do I have to also upload this ga_keyword2.js file? If so, why?

Thanks so much - really looking 4ward to taking it for a test drive!

S

May 19, 2010 3:55 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Sandra: Yes, replace the code on your site with the one above. And, yes, you do need to upload the file. Why? Because that's where all the code that grabs the search query is.

May 25, 2010 9:42 AM

Eric said:

Hi Michael,

I wanted to thank you for this wonderful tool. We've been using it for almost 2 years and its benefit has been significant.

Yesterday, I upgraded my site to the new asynchronous GATC code but wasn't quite sure how to integrate ga_keyword.js so I took my best shot as shown below. No luck--the user defined value data has disappeared.

Actually, there are two problems here. Whenever I originally set up the 'traditional' GATC code with the two additional lines for cross-domain tracking, the UDV info would disappeared. We decided knowing what the original queries were outweighed cross domain tracking so we just left out the

pageTracker._setDomainName('none');
pageTracker._setAllowLinker(true);

lines and lived with the compromise. This time I included the asynchronous equivalent for cross domain hoping it would work but no luck.

_gaq.push(['_setDomainName', 'none']);
_gaq.push(['_setAllowLinker', true]);

So I've changed too many variables to know what the real problem is, but if this is a no-brainer for you, would you please point out my error. Alternately, I can go back and remove the cross domain asynchronous lines to try and isolate the cause and effect and see what happens.

Also noticed an early post about deprecating the _setVar() function and an upcoming post about that? Perhaps that post might be nearby?

Would be grateful for any help.

Eric.

Current Attempt:

<!--
<head>

<script src="ga_keyword.js" type="text/javascript"></script>

<script type="text/javascript">

var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-123456-1']);

_gaq.push(['_setDomainName', 'none']);
_gaq.push(['_setAllowLinker', true]);

_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

</script>

</head>
-->

July 7, 2010 9:00 AM

Darrell said:

Google Adwords lets me generate a report of keyphrases typed that caused ads to show up and wheter they generated clicks or not. These are phrases typed during the search, including searches on other sites, not just the keyword that match the ad. I can then see phrases generating clicks that I don't like the words that are in them, then ad those to my negative keywords. Is this something new that was not available in 2008 when this ga_keyword script was created?

September 8, 2010 5:52 PM

George Strait Tickets said:

Then you can use something like Filters, Site Search or Custom Variables to pull that data out and put it into a Google Analytics report.

September 23, 2010 5:58 AM

Christina said:

I used to work at a ppc agency and our Google rep gave me a filter that let me track search partners. I did not save the filter and I don't have access to that account anymore. I can't seem to find how to do this again. Can you make a filter that does this

October 26, 2010 8:58 AM

PPC Whiz said:

This stuff is great! Keep up the good work team, I really appreciate you sharing this with the community. You are an excellent resource for us PPC guys out there looking to maximize our spend.
My clients will thank you!

February 14, 2008 3:25 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@PPC Whiz: Glad we could help out! Definitely keep posted here on any additions or updates, and like I said in my post, our own team will be posting some of their tips and tricks in the coming weeks.

February 14, 2008 4:22 PM

Jesse DaCosta said:

Hey Michael,

Thanks for the update, have been on the lookout for it! I've tried another method from another blog but that doesn't seem to work, at least for me, so now I've updated to the new code I'm going to test this out.

Thanks again!

February 14, 2008 4:37 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Jesse: Great! Let me know how it works for you. We're always trying to improve it.

February 14, 2008 5:54 PM

Christian Martin said:

Thanks for updating the ga.js script with this! I only saw the original change for the old urchin code yesterday after your webinar. I've already changed the GA code on both our site and looking forward to seeing the results in the coming days.

I do have a question... In the Traffic Sources::Keywords section, their are toggles for Show: total | paid | non-paid and then the Segment listbox.

On first glance, it would seem GA is providing everything without the script. Am I being simplistic in my cursory look?

Thanks again!

February 14, 2008 7:06 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Christian: Unfortunately, the Keywords report will only show you the bid terms for your paid search. Basically, it will show you the keyword phrase that you bid upon, but not the one that visitors actually typed into the search engine. Hope that makes sense.

February 15, 2008 9:32 AM

Dave Cardwell said:

Thanks for updating this script and sharing it with the community.

I'm curious - why the "UA-1" in this line of the script:
_gat._getTracker("UA-1");

February 15, 2008 11:51 AM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Dave: It's just a precaution, due to the way that setVar operates, and we've found that it leads to more accurate usage stats.

February 15, 2008 1:57 PM

Searchquant said:

Doesn't it seem strange that Google wouldn't make this a feature in G Analytics early on? It's clear any smart marketer's gonna want to know which queries within phrase or broad matched keywords are working and not working.

Google gets 70% of its revenue from phrase and broad match.

February 15, 2008 4:53 PM

Sonja Bakker said:

Hi,

This quiet cool. I already saw that the previous script wasn't working anymore. Going to try this one now!

February 18, 2008 11:27 AM

Julien Raby said:

Hi Michael,

thanks a lot for this new version of the script, I was using the old filter hacks but it doesn't work anymore...

One question: the script as it is now doesn't seem to work if I manually tag my link (I almost always tag my links instead of using the auto-tagging to gain more control over the utm_campaign variable...) so I was wondering if there were a quick fix fo manual link tagger like myself?

Thanks again,
Julien

February 19, 2008 6:54 PM

Mark Curtis, Paid Search Team Leader Author Profile Page said:

@Julien: While we definitely don't recommend that you manually tag AdWords ads (it causes problems when Analytics links up the data between your two acc