-
-
Notifications
You must be signed in to change notification settings - Fork 607
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Js detecting script does not detect cookie passed with sitespeed #2489
Comments
Hi @gety9 I'm not sure. First I thought it could be something wrong with how we add a cookie today. We use web extension to do it (both for Chrome and Firefox). But for Chrome we could use the ChromeDevtoolsProtol instead. What about trying to create a really simple test case and we can work from that? Any change you could help me with that? Best |
Hi there, we've created 3 cookie detections pages (js inline, js in header, js in footer) all of them detected sitespeed cookie. So seems like the problem either with GTM or with somethings else on our side... I will close it for now, will reopen if something. If you need detection pages i can share them, but the problem is not in sitespeed. |
We are still trying to solve the issue. Upon investigation we realized that 1 All Desktop Tests with cookie is correctly identified as testing (GA ID is changing to testing) Here are Jun 1 - Jun 11 stats from So seems like the problem is with Mobile Traffic Google Nexus 5. Mobile Test
Desktop Test
Do you have any ideas ? One more time we are using the following script to identify cookie and change the GA ID.
|
Hi @gety9 ok I see, the reason is that WebExtension (that we use to set the cookie) doesn't work on mobile phones (Chrome doesn't support it). What you can do right now is to use https://www.sitespeed.io/documentation/sitespeed.io/scripting/ and run Chrome Devtools Protocol commands. Checkout https://chromedevtools.github.io/devtools-protocol/tot/Network#method-setCookie. It could be that you first need to enable network by using https://chromedevtools.github.io/devtools-protocol/tot/Network#method-enable, I don't remember. Have you used CDP before? If not let me know if you need any help. Best |
In the long term I planned to add a short cut for setting the cookie that way, but I haven't had the time to focus on that yet, sorry! |
"the reason is that WebExtension (that we use to set the cookie) doesn't work on mobile phones (Chrome doesn't support it)" "Have you used CDP before? If not let me know if you need any help." |
Ah sorry I miss read your comment. I was of the impression that it works for you on desktop and running emulated mobile, but when testing on a real Android phone, it never works? |
@gety9 how do you run your tests? I've found one bug now when I was fixing another bug: If you run a script and don't navigate by a URL, (command.measure.start('alias'), the Browser Extension doesn't run (so no cookie is set). I'll try to fix that asap. |
Hmm that isn't super easy to fix, I'll created a bug for it here: sitespeedio/browsertime#859 |
the run for tests is always the same:
And we always use same script (inside google analytics, not inside sitespeed) to change google analytic ID
The problem is that though Google Analytics ID is changed to testing, in 40% of tests it also is landed in real Google Analytics. https://puu.sh/DFo6N/f50b8d444a.png |
Ok, then I understand. Hmm, so somehow then when running on 3g the cookie aren't set correctly? |
yes, the problem is either What i mean if we do 100 mobile tests, |
could you explain me how |
Turn on Chrome in emulated mobile. Checkout sitespeed.io/lib/plugins/browsertime/analyzer.js Lines 75 to 90 in 0214260
Add the string 3g as the name of the connectivity. Nothing else is set if you use Docker networks. If you use Throttle as connectivity engine, then it sets up the correct tc config for the network. |
Managed to get userAgent for this "double serving" visit for which cookie does not work, it is: Doing google search i came to So seems like it's lighthouse visit, and i can assume that cookies do not work for lighthouse in emulated or throttled mode. Here is there is cookie related issue |
Aha I see. If you set a cookie for browsertime we don't automatically set that for Lighthouse/GPSI/WebPageTest or whatever other tool you use. Sorry I missed that you are using the plus1 container. |
ok, understood How can i set the cookie to Lighthouse ? Is there a parameter so something i can add to the run that we use now ?
|
I think you can set headers with Lighthouse, check their docs. Parameters in the namespace --lighthouse.settings.* is passed on to Lighthouse, check https://github.com/sitespeedio/plugin-lighthouse#configuration |
i see, thank you I've added this to json config file
which added this to run command
let's see if it will fix it. Also why did we had this problem only with mobile tests (--mobile true --connectivity 3g) ? UPDATE: |
Yeah try something like that. It could also be extraHeaders think the doc isn't clear. You can test on httpbin just to get it right: https://httpbin.org/#/Request_inspection/get_headers |
Closing since it was a Lighthouse issue. |
Guys hi,
I am running the following command:
docker run --shm-size=1g --network=cable --rm -e TZ=America/New_York -v /usr/share/zoneinfo/America/New_York:/etc/localtime:ro -v "$(pwd)":/sitespeed.io sitespeedio/sitespeed.io:8.2.2-plus1 --browsertime.iterations 1 --browsertime.cookie trafficType=testing --grafana.host XX.XXX.XX.XXX --grafana.port 80 --grafana.auth XXXXXXX --graphite.host XX.XXX.XX.XXX --graphite.port 2003 --graphite.auth runner:XXXXXXX --graphite.annotationScreenshot true --graphite.namespace sitespeed_io.z-ohio-tmp --s3.key XXXXXXX --s3.secret XXXXXXX --s3.bucketname XXXXXXX --s3.region us-east-2 --s3.removeLocalResult true --chrome.timeline true --resultBaseURL http://XXXXXXX.s3-website.us-east-2.amazonaws.com --mobile false --connectivity cable https://www.sitename.com/'
and getting following result
Google Chrome 72.0.3626.81 \nMozilla Firefox 65.0\n[2019-05-31 10:52:51] INFO: Versions OS: linux 4.15.0-1039-aws nodejs: v10.13.0 sitespeed.io: 8.2.2 browsertime: 4.2.4 coach: 3.2.0\n[2019-05-31 10:52:51] INFO: Will run Lighthouse tests after Browsertime has finished\n[2019-05-31 10:52:51] INFO: Sending url https://www.sitename.com/ to test on Page Speed Insights\n[2019-05-31 10:52:51] INFO: Running tests using Chrome - 1 iteration(s)\n[2019-05-31 10:52:52] INFO: Testing url https://www.sitename.com/ iteration 1\n[2019-05-31 10:52:56] INFO: Got https://www.sitename.com/ analysed from Google Page Speed Insights\n[2019-05-31 10:53:14] INFO: https://www.sitename.com/ 50 requests, 744.20 kb, backEndTime: 302ms, firstPaint: 493ms, firstVisualChange: 500ms, DOMContentLoaded: 773ms, Load: 1.66s, speedIndex: 646, visualComplete85: 666ms, lastVisualChange: 1.17s, rumSpeedIndex: 1059\n[2019-05-31 10:53:14] INFO: Will collect Lighthouse metrics for https://www.sitename.com/\n[2019-05-31 10:53:21] INFO: Got Lighthouse metrics\n[2019-05-31 10:53:22] INFO: HTML stored in /sitespeed.io/sitespeed-result/www.sitename.com/2019-05-31-10-52-51\n[2019-05-31 10:53:22] INFO: Uploading /sitespeed.io/sitespeed-result/www.sitename.com/2019-05-31-10-52-51 to S3 bucket XXXXXXX, this can take a while ...\n[2019-05-31 10:53:24] INFO: Finished upload to s3\n[2019-05-31 10:53:24] INFO: Find the result at http://XXXXXXX.s3-website.us-east-2.amazonaws.com/www.sitename.com/2019-05-31-10-52-51\n
I am using following script to change Google Analytic Ids for testing traffic (so test is as close as possible to speed experienced by real user, without polluting analytics of real account)
If i manually go to my page, create cookie trafficType=testing, revisit the page than it works correctly, but if i test it with sitespeed passing cookie trafficType=testing, it does not work, though cookie is shown in in All Request Headers https://puu.sh/DzOA6/acdc29cf7e.png
What am i doing wrong ?
The text was updated successfully, but these errors were encountered: