I'm developing a Chrome application and it would be really helpful to easily know how many time is the front tab "active" (duration since the moment it becomes the front tab until the moment it changes to another tab).
I search the documentation but i couldn't find anything helpful so I'm trying to implement it using the chrome.tabs.onActivated.addListener.
Does anyone know a simpler method or any helpful library to do this ?
Thanks in advance for any help !
You can use:
document.hidden
to determine visibility state and a:
document.addEventListener("visibilitychange", function(e){ console.log(e) }, false);
to listen for visibility state change.
You can read more about this API here: Using the Page Visibility API
Related
Scenario:
I am using this module: https://www.drupal.org/project/google_analytics version 3.1
It is using Google Analytics 4. Drupal version 8.9.x
We followed the documentation https://developers.google.com/analytics/devguides/collection/gtagjs/custom-dims-mets to create some custom dimensions and added in the Google Analytics configuration accordingly.
When view the page source, I see code is added there:
gtag("config", "G-MESUREMENT-KEY", {
"custom_map": {
"dimension1":"user_company",
"dimension2":"user_role",
"dimension3":"user_badge_access"
}
}
);
gtag("event", "custom", {
"user_company":"TEST Company",
"user_role":"authenticated, member_administrator, administrator",
"user_badge_access":"Office"
}
);
Using some Chrome GA debugger "GTM/GA", I see parameter is passing there. In the request "Pay Load" of Chrome debugger it shows its sending the values:
en=page_view&ep.anonymize_ip=true
en=page_view
en=custom&ep.user_company=Surface%20Oncology&ep.user_role=authenticated%2C%20member_administrator%2C%20administrator&ep.user_badge_access=Office
BUT I don't see the data when I open DebugView in the GA dashboard! And Interesting part is, some chrome debugger like "Google Analytics Debugger 2.8" when enabled, which seems open a debugger and connect to GA dashboard, DebugView is showing the events and parameters data. So there must be something which restricting or refusing to connect with GA Dashboard to push the data.
Reads lot of documentation, did lot of test but failed to find a reason for that. The site is fully login protected but event /user/login page which is accessible to all, not sending the data at all.
If some one can shed some light on the issue, it will really really help for me. Thanks in advance.
Actually this is my mistake of my understanding. All data is pushing to GA dashboard no confusion. The reason why I don't see data when creating a comparison report based on custom dimension parameters is due to "scope" difference.
So if you want to create a report based on event scoped parameters, please go to Engagement->Events, and if you want to create a report based on user scoped parameters, please go to Audience tab, but user scoped report will not show data if captured users record is less than 10.
A documentation for reference: https://support.google.com/analytics/answer/2709828?hl=en
I need to fetch comments from this site https://russian.rt.com/, for example, for this news: https://russian.rt.com/sport/article/486467-rossiya-hokkei-zoloto-olimpiady
So I try this:
String url = "https://russian.rt.com/sport/article/486467-rossiya-hokkei-zoloto-olimpiady";
try (WebClient client = new WebClient(BrowserVersion.FIREFOX_52)) {
client.getOptions().setJavaScriptEnabled(true);
client.getOptions().setThrowExceptionOnScriptError(false);
client.getOptions().setThrowExceptionOnFailingStatusCode(false);
client.setAjaxController(new NicelyResynchronizingAjaxController());
HtmlPage rtPage = client.getPage(agencyURL);
HtmlElement comBlock = rtPage.getFirstByXPath("//ul[#class='sppre_messages-list']");
} ...
But HtmlElement comBlock is always null.
I've tried waiting for javascript to complete by
client.waitForBackgroundJavaScript(10*1000);
- scrolling page:
client.getCurrentWindow().setInnerHeight(60000);
or
rtPage.executeJavaScript("window.scrollBy(0,600)");
- getting elements at the bottom of the page and clicking them.
But neither of that helped and HtmlElement comBlock after all these operations is always null.
Maybe comments module uses some kind of websockets and this is not even possible?
Can anyone help me, please?
Have done some short tests with this site. At first i have seen a NPE when calling the site. This is fixed now in HtmlUnit. Usually i will inform via Twitter (www.twitter.com/HtmlUnit) if a new snapshot build is available. After that fix i faced many more javascript problems. Looks like the page does a lot of javascript including some uggly things. If you like to get this fixed it will be a great help if you can isolate simple cases that show the problems to give us a chance to fix HtmlUnit (there is more info about this on the HtmlUnit home page).
Sorry for not having a direct solution but as for many open source projects we need help from the community to do all the work.
I'm having some trouble with the GCP console, hopefully someone can point me in the right direction.
A couple of days ago I generated some API Keys and was able to restrict their validity scope by target API. The form looked like this, and I was able to restrict keys to apply on my GAE private APIs only:
whereas today the righthand side tab has disappeared on me and I can only apply "Application restrictions" (IP range, referrer, etc..) and I can see merely the following menu.
I was and still am the owner of the project, and I'm not aware of any change in roles/project config/etc.. (although I can't 100% rule them out)
There is next to zero documentation about the mysterious "API restrictions" tab. Hope someone can help.
Many thanks in advance
F
This feature has been removed temporarly because was causing issues with the Google Maps API.
API already created making use of these restriction will not work and the workaround is to remove them and recreate them with no restriction.
https://issuetracker.google.com/issues/69715011
Please star the bug to add your vote and subscribe to notifications from Google. Hopefully they will fix the issue soon.
I am trying to track clicks on the phone number on the website. After I set up the trigger using following settings:
Trigger Type: all elements;
Page URL: contains "tel:" ;
Click Text: contains "13";
With these settings, the trigger is firing correctly on the desktop but isn't working on mobile.
I tried to use only "Page URL"/"Text Only"/"Form Text"/"Form contains" as conditions for the trigger to fire, but all attempts are unsuccessful. I also tried to use "Just Links" as a trigger type but it's not helping.
I also tested the URL in different mobile browsers (chrome/safari) and emulator. With an emulator, the tag is firing correctly but it's not working on the
Please have a look at the preview to see the page and tracking I am talking about:
https://www.googletagmanager.com/start_preview/gtm?uiv2&id=GTM-T92J432>m_auth=MmNY2ZtOefQOp1Kce4yUFQ>m_preview=env-5>m_debug=x&url=https://lp.acfc.com.au/good-credit
I appreciate your advice on what is the problem and how it can be fixed.
Thanks!
Kirill
Actually, better way of doing this to set generic trigger in GTM, then you will be able to track any phones on your website:
1) Enable built-in variable Click Element (if you already have it, you can skip this step)
2) Create trigger, which will fire for all links which have tel:***** (it can be any phone).
CSS selector on the screenshot is a[href*="tel:"]
3) Create a tag, which will send data to GA
4) Check your events in GA.
Keep in mind that it might take a couple of hours to appear in Behaviour-> Events tab. Or you can check it immediately in Real Time -> Events tab
RESOLVED:
I just found out that in order to identify an event it is safer to look at how the data layer is changing after the action rather than on the "Variable" tab.
By doing so, you can see what data is actually going to google analytics, and it is more stable to use it as an ID for a trigger to fire.
In my case, I've had only elementURL that was pushed back to the datalayer. I used the parameter elementID equals "tel:xxxxxx" to make the tracker work. Hope it will help (just put your number instead of x).
Cheers!
So on one of our recent launches we had a lot of events that we were observer such as controller_action_predispatch. Once the site went live we started noticing that our observers were never getting called for those. After a little investigation one of our developers found this block of code in Mage_Core_Model_App around line 292
if ($this->_cache->processRequest()) {
$this->getResponse()->sendResponse();
} else {
$this->_initModules();
$this->loadAreaPart(Mage_Core_Model_App_Area::AREA_GLOBAL, Mage_Core_Model_App_Area::PART_EVENTS);
if ($this->_config->isLocalConfigLoaded()) {
$this->_initCurrentStore($scopeCode, $scopeType);
$this->_initRequest();
Mage_Core_Model_Resource_Setup::applyAllDataUpdates();
}
$this->getFrontController()->dispatch();
}
As you can see if $this->_cache->processRequest() that is true which it is when full page cache is enabled you never get to the dispatch. The developer did find http_response_send_before which gets call either way but it seems to me like this is a bug or you should never ever use those controller dispatch events for anything if you have full page caching enabled. Any thoughts?
Given the nature of the full page caching, I'd call this "works as intended". While it can be a little strange not to have some events firing, they had to pick a line and this one makes sense to me, especially since the controller is never really dispatched.
You should use those controller dispatch events for anything that affects the page (as it still needs to be generated), but if you are using it for tracking and such, no it would not be appropriate.
See here if you want to learn how Caching works with Magento Enterprise
http://magentophp.blogspot.com/2011/02/magento-enterprise-full-page-caching.html
The only reliable event to listen for with and without Full Page Cache enabled is http_response_send_before.
controller_front_send_response_before
This event will be fired irrespective of FPC enabled