How to tell google analytics that I am a bot? - selenium-webdriver

I recently wrote a tool that checks if certain requests on a web page are fired. For example is jquery from a google server loaded when I visit StackOverflow? The tool is based on webdriver and a chrome browser.
The tool works like a charm but it also generates google analytics traffic that should not be there.
Is there a possibility to tell Google that the tool is a bot and should not be counted? All solutions I found focus on the page under test and how to not collect data via Google. I need a solution that works without changing the website's code.

Possibly the easiest way would be to send a custom user agent string along and filter by that via a view filter.
Untested, but I think if you use the same user agent string as the Google crawler I'm pretty certain it will be filtered out automatically (after all Google should be smart enough to filter their own crawler). According to this page the Google crawler UA always contains the string "Googlebot" (else youD have to go through your server logs to find a likely UA string).

We solved our problem with a chrome extension. That extension redirects all requests against the google collect endpoint to example.com. Works like a charm.

Here is the Answer to your Question:
It sounds interesting to know about a tool which checks if certain requests on a web page are fired for e.g. jquery from a google server loaded.
Practically, there is a lot of difference when a page e.g. StackOverflow.com is opened Manually (through keying in the URL manually) and when chromedriver exe is used to initiate the new Google Chrome session.
As an example, manually when we open a new Google Chrome session, the command line parameters which gets passed along with chrome.exe are --flag-switches-begin and --flag-switches-end only.
But when we try to use chromedriver exe, we generally take help of ChromeOptions class and DesiredCapabilities class to add various config parameters to the Google Chrome session. Apart from all these one parameter is added i.e. --test-type=webdriver.
Hence any website when accessed by chromedriver exe is always aware that it's a Automated Bot.
Let me know if this Answers your Question.

Related

NextJS advice for SSG/SSR and Google Analytics/cookies

I have a NextJS site which is statically generated at build (SSG).
There are two things I need to implement next
Google Analytics
GDPR compliant opt-in cookie options
The first one is easy enough to do, however i'm struggling with making this GDPR compliant.
The issue is I don't have access to cookies at server side when my site is statically generated. This means that without knowing whether the user has consented to cookies at the server, I can't serve (or not serve) the analytics script along with the rest of the page.
Possible solutions:
Handle everything at client side - ask for consent, then dynamically add the GA tag to the <head>. However i'm worried this will negatively effect the analytics, or break it altogether. Does anyone know?
Change my site to be server-side rendered (SSR). I'd love to avoid this if possible. I'm really happy with how fast the site is running with SSG. It's essentially just a basic blog so would be a shame to have to convert for the sake of analytics.
Any other ideas?...
If anyone has experience with this, whether they used Next or Nuxt, etc, your input would be greatly appreciated!
Thanks in advance
Use Google Tag Manager to manage everything, your GA integration and your cookie integration using something like CookieHub for example (How to set up Google Analytics through Google Tag Manager for Next-Js?)
GTM will allow you to trigger the GA script only if the user specified he accepts analytics cookies.
Eitherway you could use Vercel.com built in analytics since your website is using Next.js wich is Vercel's framework.

Selenium Tests-Verify login

I have a web application which starts with user login page. I need to test this login process. If the user is in his home country then he is directed to his user page. But, if he logs in from a different country he is shown an authentication page before directing him to his user page. The authentication page has some security questions that need to be answered. I have used a chrome extension(Geo Proxy) and sikuli to change the proxy address. But, the page takes too much time to load and hence, my test fails.
It looks like it is possible to spoof your geolocation for the ChromeDriver. You may be able to try this approach..
ChromeOptions are essentially settings that you pass to your ChromeDriver, may be possible to do here as well. Here is an answer for this using python, I am sure you can find examples for whatever language you are coding in. Just do some research around geolocation and ChromeDriver/ChromeOptions.
fake Geolocation in chrome automation

Why is Google Compute Engine not allowing me to create image?

I'm trying to implement wowza streaming engine with google cloud using this tutorial.
The problem I am having is that when i try to add the Wowza Streaming Engine image via the developer console it fails saying " Required 'read' permission for 'rawDisk.source' ". I have also tried adding the image via the command-line tool with no success.
From my research on this error, all I have been able to surmise is that maybe this particular image is no no longer publicly shared, but this seem highly unlikely.
So I tried exactly what you said, followed the same tutorial and got the same error. While the tutorial is somewhat out-dated (as certain commands are no longer the same and so on), the image they provide should still be fine. I wasn't able to create my image via the Web UI but it WORKED via CLI.
Here's what you can do as a workaround:
gcloud compute images create [IMAGE_NAME] --project=[YOUR_PROJECT] --source-uri http://storage.googleapis.com/wowzamediasystems/wse/WowzaStreamingEngine-4.1.0.v2.image.tar.gz
As long as you're properly authenticated (for example gcloud auth login) the above command should work. I tested, and was also able to create my instance using the image it creates. SSHed to it without a problem.

GAE Launcher enforce Google account signin in app.yaml

Firstly, just letting you know I have searched a fair bit here and I am aware of some of the other questions on this topic but none answer my question.
The authentication of the Local GAE differs from the appspot deploy and I need it not to with minimal work-around code.
I'm writing an HTML5 app and I can do the google authentication via a button and it updates all the correct tokens so I can access the profile in either GAE Launched apps or appspot deployed ones.
I need the google account details of the logged in user within the app
I am writing (for API calls to calendar and contacts for example)
, and I'd rather not have to write a login handler only for my local development platform - automated for simplicity or otherwise.
I've read that adding login:required forces a login, and on appspot this works perfectly. Locally it does nothing useful.
I've read that you can write a Python decorator to use #login_required - but I'm not writing in Python (It's php generating an HTML5 page). I could write a bit of a PHP wrapper to handle it, or automate a call in Javascript on page load - but this is the workaround I don't want to write because it's handled in the production environment for me.
I want the login:required option as everything is handled for me in
production
. I have googled the options for the login tag and nothing there suggests I can force a google login in the locally launched app. I have googled the launcher and settings, but nothing seems apparent.
I suppose I could live with the dev workaround, and the app could assume I'm authenticated and the JSON request handlers in my app would just use the login:required with the correct google tokens being passed once I am authenticated.
Do I have any other options?
This sounds like it could be a PHP runtime bug. login:required works fine on the python local dev server. Have you checked the issues page to see if it's been reported?
https://code.google.com/p/googleappengine/issues/list
Otherwise it's possible that it's bypassing the login on your dev server because you have some cookie in your browser indicating that you're already logged in. You might try clearing cookies
Alternatively (at least on the python devserver), you can go to your login page via http://localhost:8000/_ah/login to force a logout (obviously fix the hostname and port number)
There appears to be no way round this other than to write the whole OAuth handler yourself (or get one elsewhere) - significant overkill for a development environment only 'issue'.
I have written the app to handle the getting of the google profile details as it starts and force an authenticate if they are not present.
This means that the login:required will work as expected in the production world and force you to authenticate to google before you even get to the application... then the app just gets the profile details because the tokens are already present.
login:required in the dev environment just puts up a screen which you just 'ok', then the app attempts to gets the profile details but forces the authentication itself because there are no authentication tokens present.
It's unfortunate, but it's a single step in a development that users will not have to use, but it works.

Embedding client ID in Chrome Extension for Server on Google App Engine

I am trying to find out as to what is the most appropriate way through which I can embed a client ID with my Google Chrome Extension? My intended purpose is that the end user can add my extension either through my website or through chrome store but he needs to provide an email address before doing that. Which could be appropriate in terms of achieving the functionality.
I studied about chrome extension on internet and one of the approach that I am thinking is that the end user can add the extension and whenever I receive the first request from user, I can generate an unique ID and embed it in to client's extension. Is it possible to modify the manifest file in order to do that and in case if I am doing this also I have no option to get the email address from the end-user. One of the approach can be also that I could do all the stuff at server side when the end user comes to add extension through my site, but how it is possible with GAE as GAE doesn't allow us to modify the contents of the file.
My application will be deployed on Google App Engine.
Also, to add is there a way through which I can modify the details of the client ID, in case if I need to do it in future?
Please advise.
Thanks.

Resources