- TLC Home Home
- Discussions Discussions
- Documentation Documentation
- Knowledge Base Knowledge Base
- Education Education
- Blog Blog
- Support Desk Support Desk
08-11-2017 09:09 PM
We need to consder bounce rate for those users whose time on page is less than 30 seconds.
We want to trigger an event when user spends at least 30 seconds on the site. We want to send this to only Google Analytics and also for a particular website. As this configuration will be done in the profile which hosts more than 30 websites so we dont want this to be applied for other sites.
Any suggestion?
08-14-2017 09:35 PM
Prior to answering your question, I wish to clarify that the approach which you are intending to take to trigger an event on bounced users isn't a good option; as you could filter down on such sessions in your analysis later but you cannot get back the lost data.
Regarding the use of a single profile on multiple websites I strongly discourage this as well since it would complicate tagging across your marketing needs. The benefit would be that you only to update a given change once, but managing them for 30 distnct sites would complicate tasks a lot.
Nevertheless, if you wish to proceed with the above, you could do so by using a JavaScript extension and writing a bit of code to trigger when the user is closing the tab or browser. Thereafter you could use location.hostname to check for the particular website which you want to trigger the event on. You may need to manually code the event such as,
ga('send', 'event', [eventCategory], [eventAction], [eventLabel], [eventValue], [fieldsObject]);
As if you could the utag view or link calls it would cause other issues if you have other events in place on the same page.
08-15-2017 03:13 AM
Just to add to @Yoosuf comment.
If you want to track a user after x amount of time you can use:
window.setTimeout(function(){ utag.view({<....data...>}, null, []); },30000);
This can be done in a JS extension, where you can now also set conditions for this to run.
Adrian
08-15-2017 11:26 PM - last edited on 08-16-2017 07:54 AM by kathleen_jo
Hello @shailesh_gaikwa. Another way is to just calculate the session time spent for every new page request:
var sessionTime = b._t_session_id;
var currentTime = new Date().getTime();
var elapsedTime = new Date(currentTime - sessionTime).getTime();
b._bContext_session_time = Math.floor(elapsedTime / 1000);
Put the result in a utag variable and use it in your load rule.
10-27-2017 04:45 AM
Hi @per_lundqvist,
'i tried using the following syntax but nothing is not happening, neither any event is being triggedred -
var sessionTime = b._t_session_id;
var currentTime = new Date().getTime();
var elapsedTime = new Date(currentTime - sessionTime).getTime();
b.TimeOnPage = Math.floor(elapsedTime / 1000);
I am using "TimeOnPage" to store the time spent by user. since it is divinding by 1000 so it should convert the value for seconds.
I have put a condition that if TimeOnePage = 30 then it should fire an event but it isn;t firing any event.
Any further guidance over this?
08-01-2021 06:31 PM
Copyright All Rights Reserved © 2008-2023