简体   繁体   English

带有.htaccess的Google Campaign和Analytics URL

[英]Google Campaign & Analytics URLs with .htaccess

One of our clients is launching a campaign around our city and one of the requirements they want is to track from what item a visitor has scanned in a QR code. 我们的一位客户正在我们城市周围发起一项运动,他们想要的要求之一就是跟踪访客在QR码中扫描过的物品。 To achieve this I have entered this into my .htaccess file: 为此,我已将其输入到我的.htaccess文件中:

RewriteRule ^(beermat|poster|flyer)$ /video?utm_source=$1&utm_medium=PrintedMaterial&utm_campaign=VideoCampaign2012 [R=301] 

So if anyone scans in the QR code that has the address: http://www.website.com/beermat it redirects to /video with the relevant attributes. 因此,如果有人扫描具有以下地址的QR码: http : //www.website.com/beermat,它将重定向到具有相关属性的/ video。

If I have the google analytics code on the /video page this should work, correct? 如果我在/ video页面上有Google Analytics(分析)代码,则该代码可以正常工作吗?

I think it would be better for you to make "poster" a directory, and the index.php inside it should set $_SESSION['found']="poster" then redirect to the main page which would read from the SESSION. 我认为最好将“海报”设置为目录,并且其中的index.php应该设置$ _SESSION ['found'] =“ poster”,然后重定向到将从SESSION读取的主页。

The added benefit is that you're not left with any ugly GET data, just a nice clean url, but the downside is that you have to manually create the directories, so only do this if you have a manageable amount. 额外的好处是您没有留下任何丑陋的GET数据,只是一个干净的url,但是缺点是您必须手动创建目录,因此只有在数量可管理的情况下才这样做。

Try this plugin to see if google-analytics is recording anything. 试试这个插件,看看google-analytics是否正在录制任何东西。 This way you can see directly if it is working or not. 这样,您可以直接查看它是否正常工作。

https://chrome.google.com/webstore/detail/jnkmfdileelhofjcijamephohjechhna https://chrome.google.com/webstore/detail/jnkmfdileelhofjcijamephohjechhna

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM