Please I'm looking to set up tags on GTM to fire only once per GA session. However, I'm unable to do so.The tags end up firing multiple times in the same sessions.
Would appreciate it if anyone can help.
Many Thanks :)
Just set a session cookie as a flag after the event has fired the first time.
The events trigger should be configured to fire only, when the cookie does not exist.
You could use sessions storage as well, but it doesn't work for new browser tabs.
So let's assume you have two conditions, that have to be checked for a session to be high quality.
What I would do ist create a session cookie (see https://www.analyticsmania.com/post/cookies-with-google-tag-manager/), that contains a stringyfied object:
{
"condition 1": "true", //has been fullfilled
"condition 2": "false",//has yet to be fullfilled
"event_fired": "false"//flag to fire event only once per session
}
Whenever a user acts in a way, that should update this cookie, you fire a custom HTML Tag, that reads & updates it. If all conditions are met and the key "event_fired" equals "false", the tag also executes a dataLayer.push event, that you can use to trigger an event, that marks the session as high quality. In addtion to the dataLayer.push event, the HTML Tag then sets "event_fired" as "true" - thus preventing the dataLayer.push event to be executed again.
Related
I'm using userId feature on google analytics to track users event.
I want stop or pause user's lifetime (or maybe it is called session duration time), depending on:
(<any>document).addEventListener('visibilitychange', function () {
if ((<any>document).hidden) {
// sendEvent : hidden
// stop or pause counting user's session
}
else {
//sendEvent : visible
// sendEvent : continue lifetime time counting on same session
}
}
To resume I don't want count time user is on site if user is hidding the page, i want consider it as he's is not on site.
You need to send a hit to Google Analytics with session control parameter set to end. I suppose detecting a document 'blur' event and sending a relevant hit to analytics would work for you.
Here is the doc on session control https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters#sc
I want to make a purchase order manager, where a queue is created from a database and then assembled into an accordion. Then, the user can look at requests, and then check the request when it is done. The task will then move to a "completed purchases" list.
I've been using a "notPurchased" datastore with the following server script:
query.filters.purchased._equals = false;
return query.run();
And then when the "submit" button is pressed, I call datastore.load();. However, this doesn't seem to refresh the purchase queue immediately. I have to completely refresh the page in order to see purchase request moved to 'completed'. How do I make this change instantaneous?
I figured out a solution that reduced any lag. Instead of filtering the database with a query, I bound the 'visibility' property to the proper boolean flag. Now items move instantly!
There are multiple ways to leverage ASP.Net MVC response/output caching. At the simplest you can cache a simple page that's the same for everyone:
[OutputCache(Duration=24*3600)] // cache 1 day
public ViewResult Index() ...
You can vary by specific params, you can bust the cache by a custom key. In all of those cases, the declarative OutputCacheAttribute is used to determine whether the page should just serve from cache. If it does serve from cache, the Action doesn't fire - CPU time saved.
So, suppose the Action accepts an Id, meaning its contents vary id to id. Suppose you want to bust the cache for specific Ids when their underlying data changes. MSDN says to set VaryByCustom inside the Action instead of declaratively in OutputCacheAttribute:
Response.Cache.SetVaryByCustom
Like:
[OutputCache(Duration=24*3600, VaryByParam="id")]
public async Task<ViewResult> Thing(string id)
{
Response.Cache.SetVaryByCustom("thing-" + id);
// Some big load of work we'd like to avoid when a ton of visitors hit
// the server goes here.
So... in every scenario until this one, that big load of work in the Action gets skipped if the page is valid in the cache. But it appears here it's not - unless SetVaryByCustom can interrupt the Action? How does this command work exactly?
If it doesn't interrupt the Action, is there some follow-on check I can do to see if the cache picked it up, so I can return early? And what would I return, given it's normally expecting a whole page filled with data?
Based on testing, it appears to work neither of the ways I proposed.
In my Action with this strategy applied, I:
Fire a log event
Fire SetVaryByCustom(id);
Fire another log event
And here's what I saw:
BrowserA: Visit a given id
Log: Both events fire - before and after
BrowserB: Visit same id
Log: (nothing)
BrowserA: Change id so an Invalidate fires for id
BrowserB: Visit id, sees 200
Log: Both events fire - before and after
BrowserA: Visit id, sees 200
Log: (nothing)
BrowserB: Visit id, sees 304
Log: (nothing)
In other words, the entire Action doesn't fire, just like in the static/declarative approach where it's all done in OutputCacheAttribute. What's pretty strange is each time it invalidates, the key gets an opportunity to change - you could pass a new key to SetVaryByCustom once per invalidation, but not more.
Unless you explicitly tell ASP.Net not to, the browser is also told to cache these pages, for the length of time remaining in the 24-hr period (via max-age). That means depending on how your visitors arrive, they may not see the page change as you intended. You can prevent this of course with Location=OutputCacheLocation.Server in your OutputCacheAttribute.
In any case, my core objective is in fact met - the server skips the CPU cost of the Action - just a bit more than I anticipated.
I'm experiencing issues with the Google Calendar API.
When deleting an event instance that instance belongs to a recurring event made from an RDATE I never get consistent answers of if it is deleted (read "cancelled") or not.
From my experience the after event instance is deleted via the API the status becomes "cancelled" as you would expect. But I can only see/confirm this if I do an API GET call.
If I do an Google API List call (getting all the instances) show the status is always "confirmed" and the event instance appears whether or not showDeleted is true or false.
Also if I do an API instances call on the master recurring event... they all show "confirmed"... none display "cancelled"... yet I know I deleted one and GET gets the result.
Does anyone else have this issue? Or have a solution. (and EXDATE is out...as I don't affect other event instance data stored which gets wiped if I change the recurring rule...)
how to display something one time every hour in asp.net ?
example for show messeage in Begining hour one time only?
i use for asp.net ajax timer control?
protected void Timer1_Tick(object sender, EventArgs e)
{
MessageBoxShow(Session["playsound"].ToString());
Session["playsound"] = 1;
}
but alway null?
---------------------------
Message from webpage
---------------------------
Object reference not set to an instance of an object.
---------------------------
OK
---------------------------
Sounds like your session might have timed out. If, between AJAX calls, your session expires on the server, then the ToString invocation may be operating on a null reference:
MessageBoxShow(Session["playsound"].ToString());
This would appear to coincide with what the AJAX client script is attempting to tell you.
This could also be the result of Session["playsound"]; being uninitialised.
The default session expiry duration for ASP.NET is 20 minutes, which you should be mindful of if you're executing an hour long timer.
You can use the
window.setInterval
method
It calls a function repeatedly, with a fixed time delay between each call to that function.
intervalID = window.setInterval(func, delay[, param1, param2, ...]);
Read more info
window.setInterval
On the client?
The only way I know to do this is via a javascript timer.
One way of doing this could be to have an session variable with NextTime to show the item on the page. If its null one could display the item now (or get the NextTime scheduled). On every page refresh, if the current time is after the Next Time, show the item and reset the NextTime session variable to the next Hour.
This would only work if the user is navigating the site and the page is being refreshed.
You can use the javascript variable window.name which keeps its value between page refreshes.
You could store a 'last checked time' in there and compare it with the current time.
If the user navigates to another site and that site clears this variable then your back to square one.
An easy answer would be to use a small cookie to store the original time and then query it every so often (~5 min?) this way the session won't run out and you're not SOL if the user leaves the page (if that's what you want).
DISCLAIMER: I haven't really dipped my toes into AJAX yet even though I've been programming ASP.net all summer, so excuse me if this isn't possible.