Can you echo Google Analytics data into the page it's fired on?

Joined
Apr 7, 2016
Messages
269
Likes
171
Degree
1
I want to change page content based on the traffic source channel groupings in Google Analytics. There appears to be a solution that used to work before Universal analytics that parsed the cookie. I'm not sure this data is available anymore. Does anybody have any suggestions?
 

Ryuzaki

女性以上のお金
Staff member
BuSo Pro
Digital Strategist
Joined
Sep 3, 2014
Messages
3,340
Likes
6,089
Degree
7
I don't have a solution but I didn't want to leave you hanging with a zero reply thread. I'll think out loud in hopes it helps you think of something.

The cookie isn't going to fire until the Analytics code has been loaded by the browser, which means you can't change the content server-side, because the content has to render before the browser gets the cookie since the Analytics code is embedded in the HTML. I'm guessing there might be something funky you could do if you have a progressive web app style site using React or whatever. But for your normal site setup with something like PHP/MySQL this will be the case.

If you can get the data out of cookie after the fact I'm sure you could change the content using Javascript/jQuery afterwards. You'd need to serve Google some static version if you care about that. This all might impact the perceived loading time by the user depending on how fast all of this can happen, which is hinging on Google, which puts it out of your control too.

What exactly are you doing here? Is this for some kind of specific lander or for general content? If it's for a lander there's probably far better options. If you're trying to hotswap content around on your site in general, like the homepage as a lander, and it's for a marketing campaign you can definitely do this using URL parameters, but you can't stop people from sharing the wrong URLs to the wrong platforms.
 
Joined
Apr 7, 2016
Messages
269
Likes
171
Degree
1
I appreciate the brainstorming! I'm looking to make a simple call tracker by traffic channel. So javascript or jquery could work because I would only be switching a phone number.

I could avoid Google Analytics altogether and have it check $_SERVER["HTTP_REFERER"]; against a table of common traffic sources. Not sure if that's creating a lot of excess bloat though. I'd have to think that through more. I would like to be able to apply this sitewide.

I would like to apply it to more than just campaigns but if I did go that route I could reuse some of the code I used from my amazon affiliate link tracking I made a while back.
 
Joined
Jun 19, 2015
Messages
23
Likes
11
Degree
0
It's DevOps so maybe this is blasphemy but there's plenty reasonably priced tools you can do this with? In my company we've been using Sitegainer for most clients recently.
 
Joined
Apr 7, 2016
Messages
269
Likes
171
Degree
1
It's DevOps so maybe this is blasphemy but there's plenty reasonably priced tools you can do this with? In my company we've been using Sitegainer for most clients recently.
Not opposed to it if I run out of options. I'll take a look at Sitegainer