最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Tracking Hashtags & Querystrings in GA - Stack Overflow

programmeradmin1浏览0评论

I have a few stickers which contain my website's URL QR Code (like this : .php?s=5&d=http%3A%2F%2Fissocial%23qr) . I will stick it to streets. As you can see if someone read this QR code, he will forward to page.

Now i want to track people who reach my site via this QR Code Stickers. Sadly, Google Analytics isn't tracking hashtags.

Maybe i can do it with querystring (like : /?qr=true) . But GA isn't tracking just one querystring.

So, have you any idea about this?

I have a few stickers which contain my website's URL QR Code (like this : http://qrcode.kaywa.com/img.php?s=5&d=http%3A%2F%2Fissocial.net%23qr) . I will stick it to streets. As you can see if someone read this QR code, he will forward to http://issocial.net/#qr page.

Now i want to track people who reach my site via this QR Code Stickers. Sadly, Google Analytics isn't tracking hashtags.

Maybe i can do it with querystring (like : http://issocial.net/?qr=true) . But GA isn't tracking just one querystring.

So, have you any idea about this?

Share Improve this question edited Jun 14, 2013 at 4:13 Yahel 37.3k23 gold badges106 silver badges154 bronze badges asked Jul 19, 2011 at 22:40 ErayEray 7,12816 gold badges73 silver badges124 bronze badges 1
  • What about a QR Code of a link with campaign parameters ? qrcode.kaywa.com/… would point to issocial.net/… – Open SEO Commented Jul 20, 2011 at 22:29
Add a comment  | 

4 Answers 4

Reset to default 12

Google Analytics's default implementation ignores the anchor, ie, everything after #, so you need to pass through the value manually. _trackPageview can accept a 2nd parameter that allows you to pass pageview values manually.

By default, GA's pageview is just location.pathname+location.search. So, all you need to do is pass through that with location.hash.

_gaq.push(["_trackPageview",location.pathname + location.search + location.hash]);

Universal Analytics

With the newer UA API, the command should be:

ga('send', 'pageview', { 'page': location.pathname + location.search + location.hash});

You can use a combination of _setAllowAnchor and _setCampMediumKey to force Google Analytics to (a) use your hash tag as a query string and (b) use your 'qr' in place of the normal utm _medium (or any other of the campaign variables).

More here : http://code.google.com/apis/analytics/docs/gaJS/gaJSApiCampaignTracking.html

Update

In the new analytics.js it should be

ga('create', 'UA-XXXX-Y', {'allowAnchor': true});

No web server can track hash tags. They aren't sent to the server; they're only used by the client.

You could always just encode http://.../qr and have your server redirect to your home page. Or just have it serve up the same content as the home page in response. Or go through a shortener.

发布评论

评论列表(0)

  1. 暂无评论