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
-
Display Networks Less Expensive Than the Google Display Network/GDN
Hi Everyone, Are there any display networks that are notably less expensive than Google's Display Network? By this, I mean less than $0.01 U.S. CPC's for real people and not bots. On the Google network, I've tried the trick of opening a sister account with a cheaper currency, but in the end, I wasn't able to get much lower than $0.01 U.S. per click after converting back to U.S. dollars. Thanks, Andy
Affiliate Marketing | | AndyRSB0 -
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 -
In what ways would an affiliate site be okay with Google?
I know Google has slammed affiliate sites hard. But affiliate marketing can be a real business and had an idea for one, but I would like to know if ALL affiliate sites are looked at as evil in Google's eyes, or if it's just those with thin and duplicate content in the product descriptions. I know they want brands to come up ahead of affiliates of that brand, and that makes sense. If I sold Acme Widgets products, Acme Widgets itself should come up ahead of my site. But what if the site sold widgets in general, with the term widgets not a branded keyword? If all product descriptions are unique and well-written content, on a site that is high quality, would it still be downgraded by Google just because there are affilate links in it? I guess overall the question could be boiled down to, are affiliate sites hit because they have horrible content or because they have links to affiliate programs in them?
Affiliate Marketing | | bizzer0 -
Which affiliate programs pass the best SEO value through their links?
How good is Google at detecting the affiliate nature of those links? How does this rate as a linkbuilding strategy?
Affiliate Marketing | | menachemp0 -
Google Analytics Tracking Pixels for Third-Party sites???
Hello, Does anyone know if it is possible to track an event on a third party site and have it post back to your Google Analytics account? For example, I am sending traffic to a partners site and I want to know if that traffic I am sending them will hit a specific point of conversion (a sale) and I'm wondering if it possible to place a tracking pixel on their thankyou.html page that gets recorded in my google analytics?
Affiliate Marketing | | shawn810 -
Does Any Know How Long It Takes Google Adsense to Approval App?
Does Any Know How Long It Takes Google Adsense to Approval App? I have been waiting almost a month.
Affiliate Marketing | | AppleCapitalGroup0 -
How long will it take for Google to forgive us?
Hi all, The last few weeks we started working on several affiliate websites. All was fine, the number of pages indexed in Google increased, rankings increased, visitors increased but; After two successful weeks Google noticed what we were doing and decided to crash our party. What we did; Create an affiliate website presenting shoes for ladies (15.000+ pages)
Affiliate Marketing | | footsteps
Create an affiliate website presenting brand shoes only (25.000+ pages)
Both sites were new domains and we linked them to each other. Biggest boo boo's we think we have made; We didn't put a no follow on the affiliatelinks We linked the websites to each other causing google to spot 25K new links to a new domain. Stuffed the index with 40K new pages out of nothing Didn't exclude the correct parameters in webmastertools so all items got indexed a multiple times. The above resulted in a drop of 95% of visitors and 3 weeks down the road we gained 10% from our low point. All boo boo's are corrected the last few day's and now we are wondering; How long will it take for Google to forgive us? And are we correct in concluding we messed up big time? Hope to hear your insight and let this story be a warning to others trying on this endeavour. Kind regards, Gerwin0