Passing Google Analytics Variables Through Javascript?
-
Alright so here's my situation and hopefully someone can help...
I want to be able to pass Google Analytics variables onto my affiliate links so I have some better conversion tracking data (not PPC traffic so no easy dynamic keyword insertion variables).
I want to do something like this:
User searches "keyword" in Google > User lands on mysite.com > search data is assigned to global variables that I can use in my affiliate link redirect script.
afflink.com/?id=123&keyword=[GA keyword variable]
Anybody know how I would go about doing that? I've seen other Non-GA tracking scripts do this but I can't figure it out here and it's driving me crazy!
Thanks,
DrewEDIT: Just figured it out after a lot of guess and testing... I'm not sure if the way I'm doing it is the fastest, most optimized way but it works.
Solution: I can pull the GA cookie and break it down to retrieve the keyword using PHP. For anyone searching for this in the future, here's how I did it:
$gacookie = $_COOKIE['__utmz'];
$keyword = substr(strstr($gacookie, 'utmctr='),7);?>
Then I can use the $keyword variable wherever I need it. I haven't actually tested this on a live site yet but everything is working fine as of right now.
If anyone has a better solution please feel free to answer.
-
I'm not sure if this is what you mean..
You want the keyword from a google search to show up on your afflink?
Got a burning SEO question?
Subscribe to Moz Pro to gain full access to Q&A, answer questions, and ask your own.
Browse Questions
Explore more categories
-
Moz Tools
Chat with the community about the Moz tools.
-
SEO Tactics
Discuss the SEO process with fellow marketers
-
Community
Discuss industry events, jobs, and news!
-
Digital Marketing
Chat about tactics outside of SEO
-
Research & Trends
Dive into research and trends in the search industry.
-
Support
Connect on product support and feature requests.
Related Questions
-
Does Canonical Tag passes link juice to the original URL?
We are using Canonical tags at almost all the pages of our eCommerce website. We have various sorting options like "High to Low", "Best Sellers", etc., due to this page URLs get change with some dynamic URL parameters. To avoid duplicity, we are using canonical tag on each page which point to the original url. Also, we are using IBM Coremetrics to track traffic and conversions, but to measure referral traffic in Coremetrics, we have to add tracking parameters in the URL. So, while link building we need to share URLs with Coremetrics tracking parameters in the URL, but the canonical of this page is pointing to the original URL. Suppose we have a Page that needs to be shared with Coremetrics tag: domain.com/category-name/?cm_mmc=Referral_-xyz--izUPF8VmRng--3 This Page has the canonical tag pointing to the original url: domain.com/category-name/ My question is if the URL: domain.com/category-name?cm_mmc=Referral_-xyz--izUPF8VmRng--3 got shared on other websites, will it pass link juice to the original URL: domain.com/category-name.
Affiliate Marketing | | Ramendra.Singh0 -
Google Hotel Finder
Hi, I have a client that wants to get started with Google Hotel Finder, can anyone offer any resources to help me get them started? I've reviewed the documents Google has published regarding hotel finder, but it doesn't really breakdown any information on how to get indexed, only that they're "pulling from a number of different data sources". Any and all insight you guys can offer would be great, thank you in advance!
Affiliate Marketing | | maxcarnage0 -
Why do my Google Analytics campaign URLs not show up in reports?
Hi guys, I'm puzzled because of my affiliate campaign URLs not showing up properly in my Google Analytics reports. I'll try to explain what I did and I hope some of you can provide advice on how to proceed from there on. What do I want to do?
Affiliate Marketing | | NHA_DistanceLearning
Actually, what I want to do is quite simple. I tagged a few URLs for Google Analytics to show up in my campaign reports. I used the URL builder to do so. Example: http://www.nhad.de?utm_source=affiliate&utm_medium=zanox&utm_content=banner&utm_campaign=105x139. Is that the entire URL?
Uhm, no. Because of the active de-duplication script on our website, I need to put some characters in front of it: **www.nhad.de/affiliate.aspx?NETWORK=ZANOX&NEXTURL=**http://www.nhad.de?utm_source=affiliate&utm_medium=zanox&utm_content=banner&utm_campaign=105x139. Yikes. Yes, I know. What do I see?
Basically, when I paste the above url and run it in (for example) Chrome, only this shows up in my browser: www.nhad.de/?utm_source=affiliate. In my Analytics reports, the campaign URL is not recognised, just the source in my traffic report. The medium is indicated with 'not set'. What am I doing wrong, and what can I do to make my campaigns appear in Analytics? Best, Bas0 -
How to rank in google local listings with multiple entities?
I actually have a portal with multiple listings from different users. Every listing is a physical shop with a different address, but more than the half of them doesn't have a website. I was thinking on creating a local business for them and then add a link to my website in the section where google asks for your web address. Does anyone already made something similar? does google allows links to inner pages and from multiple domains? Do you have any other and better idea on how to show in local results if you're like an affiliate and not the direct owner of the shop? With google local listings crowding the serps it should be interesting to know how to fit in there.
Affiliate Marketing | | mememax0 -
How many characters will Google read in a header space on a page?
We heard that Google will read about 2,000 characters in a page header. We are using DoubleClick and need to insert more than 2,000 characters in each page header. Any insight?! Thanks!
Affiliate Marketing | | theideapeople0 -
Google Panda & Effects On Affiliate Sites
Quick Question, We all have heard that outbound links for affiliate marketing will be filtered via Panda however how does this work when using the Google Affiliate Network URL's? Has anyone found different signals with using Google vs. Another Network?
Affiliate Marketing | | Ben-HPB0 -
Duplicate versions of pages on my site are getting indexed by Google...I think...
Hello, Our site has a very high bounce rate, which in part is down to a slightly old fashioned design, and also because we are a retailer and I imagine many visitors are simply quickly comparing prices and then leaving. However, having had a look in Google Analytics, I think that there is another issue that is contributing to a very high bounce rate. When I look in Content > Top Content, and order the pages in order of Bounce Rate, high to low, there are hundreds of instances of pages with just one or two visits in the last month, and a 100% bounce rate. The links are the same as our home page or pages on our website, but with extra letters and numbers at the end of the url. We have an affiliate scheme, which provides our affiliates with unique codes for the products they want to link to, and my guess is that these urls are getting indexed. I've looked at a few other links, and they go to translated versions of a page from our website, generated by Google. Other urls seem to have been generated by search results from our own search on the website. What worries me is that there are lots and lots of versions of the same page, with slightly different urls. I am by no means an SEO expert - I work for a very small company and am basically learning as I go - but I know that duplicate content is bad news. If the pages were on our own site, we could use 301s to redirect, but what about translated versions, or urls generated by affiliate schemes, or search results? Many thanks, Sophy
Affiliate Marketing | | sophycolbert0 -
How Google Shopping Relevance Determined?
After looking at Google Shopping results, I was wondering how the "Relevance" is determined. It would obviously be hugely beneficial to be ranked as one of the top 5 most relevant products, since that is the default sorting criteria. Originally, I thought it was a combination of Price and Seller Rating. But after examining a few examples, that doesn't seem to be the case. When doing a search for "Radian XTSL" - a car seat that our website features - JustKidsStore.com appears at/near the bottom of the Google Shopping list, despite having a competitive price and ranking well for that term organically (8-13). http://www.google.com/products/catalog?q=radian+xtsl&hl=en&safe=off&cid=15471698622239402479&os=sellers# Do you know what the ranking factors are? And if so, can you give a few pieces of advice for best practices? Thanks!
Affiliate Marketing | | BarrettAhern0