Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Orion · Jan 16, 2019 at 03:48 PM · wwwgooglewebrequestbotsspider

Unity 2018 hits don't show in Google Analytics

Since moving to Unity 2017/2018 from Unity 5.6, suddenly analytic data to Google Analytics does not arrive anymore. The server says 200 (ok) and there are no errors whatsoever. If the same url is used in the browser, the hit shows as expected. When comparing the traffic between a working 5.6 version and a non-working 2018 version, there is almost no difference:

 GET
 https://www.google-analytics.com/collect?v=1&ul=en&sr=1
 >>    blablathequery
 HTTP/1.1
 
 Host: www.google-analytics.com
 Accept: */*
 Accept-Encoding: identity
 User-Agent: UnityPlayer/
 >>    5.6.6f2 (http://unity3d.com)
 
 X-Unity-Version: 
 >>    5.6.6f2

vs

 GET
 https://www.google-analytics.com/collect?v=1&ul=en&sr=1
 >>    blablatheexactsamequery
 HTTP/1.1
 
 Host: www.google-analytics.com
 Accept: */*
 Accept-Encoding: identity
 User-Agent: UnityPlayer/
 >>    2018.2.19f1 (UnityWebRequest/1.0, libcurl/7.52.0-DEV)
 
 X-Unity-Version: 
 >>    2018.2.19f1
 
 Content-Type: application/x-www-form-urlencoded

So what gives?

Okay, I actually already know the answer, but I want to help people with the same issue (including future me). Here it comes:

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by Orion · Jan 16, 2019 at 03:59 PM

Unity 2018 is registered as a known bot or spider in the IAB/ABC International Spiders & Bots List!


What the flying f*? That's what I spent the last four days rebuilding my analytics code in all possible configurations for?

Well. Turns out there is a little checkbox in Google Analytics > Admin > View Settings > "Exclude all hits from known bots and spiders".

When checked, if the user-agent is 5.6, it tracks just fine. If it's 2018, it gets ignored.

Apparently, the user-agent and X-Unity-Version of UnityWebRequest can not be changed. Which means I have to disable the checkbox in order to still be able to receive hits. Goddarnit.

I'm not filing a bug report since Google doesn't care (it's not their list) and neither will Unity since they have their own analytics solution to sell.


So there, future self. Don't you ever tick that box.


Edit: thank you @SimonBVolume for suggestion this solution. You can modify the HTTP request's client data and then GA will not treat it as a bot (in GoogleAnalyticsMPV3.HandleWWW)

 myUnityWebRequest.SetRequestHeader( "User-Agent", "UnityPlayer/2019.2.9f1" );
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
2

Answer by SimonBVolume · Nov 20, 2019 at 10:43 AM

For anyone else who finds this and doesn't want to open their Analytics up to bots, I contacted IAB after reading this post. They were able to explain that the issue is with Unity's User Agent as it's non standard and had bot flags in it. The solution is very simple, override the user agent with something sensible. The following worked for me and I can now keep bot protection on.

myUnityWebRequest.SetRequestHeader( "User-Agent", "UnityPlayer/2019.2.9f1" );

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Tomer-Barkan · Jun 11, 2020 at 06:58 PM 0
Share

Thank you so much! This solved my issue as well. Updated the answer with this info.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

104 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

WWW (webrequest)not working in windows8.1 app store build 0 Answers

how to enter another request from www with c# 1 Answer

GoogleApiException: Parameter "spreadsheetId" is missing 2 Answers

Data pass using POST method - WebRequest object 1 Answer

Download progress is -1 forever. 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges