大网数据广告活动
网站运营与故障问答

Google Tag Manger Event for 301 Redirect

· 52CE 我爱测

I have an image slider on my website. The entire slide is a link. I created a web page just to have a URL to use for a 301 redirect. Slide links to website.com/sample-page > Redirect is set to instagram.com/companyname. I tried s…

问题原文

原帖链接 · Webman · CC BY-SA 4.0

I have an image slider on my website. The entire slide is a link. I created a web page just to have a URL to use for a 301 redirect.

Slide links to website.com/sample-page > Redirect is set to instagram.com/companyname.

I tried setting up a Page View in Google Tag manager, but it was not registering in Google Analytics. So then I tried setting the page view up as an event. Still not registering in Google Tag Manager.

Is is possible that even though the website URL is clicked on, GTM is not registering anything since the 301 redirect kicks in?

已采纳解答

原帖链接 · Stephen Ostermiller · CC BY-SA 4.0

Google tag manager and Google Analytics can't run on redirect URLs.

When a browser hits a redirect URL, it only uses the HTTP headers. It looks at the Location: header to figure out where the redirect is going. It doesn't use any of the HTML or JavaScript that comes in the body of the response. Your server isn't going to even include your GTM or GA snippets in the redirect response body.

A 301 redirect will be tracked in your server logs. You can use your existing setup to see how many clicks you are getting if you can gather that information from your log files rather than from GA.

If you want to track the clicks using GTM and GA, you need to do so on the page that contains the link. GTM can be configured to insert a tag onto the link and wait for up to a couple seconds after it is clicked so that it can be tracked. Full instructions can be found here: https://www.analyticsmania.com/post/track-outbound-links-with-google-tag-manager/

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Webmasters Stack Exchange
适用范围
以原帖系统、软件版本与发布日期为准(2019-11-26)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。