Highlighted

Trigger GUA Tag every 30 seconds

Silver Contributor
Silver Contributor

Hello everyone,

 

I am looking for a code for extension to fire a GUA tag every 30 seconds. I have already saw something "after 30 seconds", but i need every 30 seconds, has anybody done it already?

8 REPLIES 8
Highlighted

Trigger GUA Tag every 30 seconds

Tealium Employee

Hello @AGoryunova 

 

You can try making use of the "setInterval" function

https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setInterval

 

This allows you to define a function / bit of code which should run every "x" seconds.

 

Something like this would work for you.

 

var GA_interval = window.setInterval(GA_event, 30000);

function GA_event(){
    var tags = [ 1 , 2, 3] 
    var data = { 
        "event_action" : "my event action",
        "event_label" : "my event label",
        "event_category" : "my event category"
     }
utag.view(data, null, tags);
}

update the "data" object with the event you want to send to GA.

update the "tags" array, with the UID(s) of the tag(s) you want to send the event directly too.

Highlighted

Trigger GUA Tag every 30 seconds

Silver Contributor
Silver Contributor

Hi @LordLingham ,

thank you for your fast reply.

 

Meanwhile i have tried a very similar code to you:

 

 function setIntervalX(cb, delay, rep) {
    var x = 0;
    var intervalID = window.setInterval(function () {

       cb();

       if (++x === rep) {
           window.clearInterval(intervalID);
       }
    }, delay);
}

utag.runonce = utag.runonce || {};
if (utag.runonce[XXX] === undefined) { 

    utag.runonce[XXX] = 1; 

       setIntervalX(function () {
            utag.link({
                           "event_category": "my event",
                           "event_action": "my action"
                    },
                    null, 
                    ['XXX']            
             )
            
	}, 30000, 20); 
}

But it generated ghost sessions - sessions without page views. 

Is there any mistake in the code?

 

Thank you in advance.

 

Highlighted

Trigger GUA Tag every 30 seconds

Tealium Employee

Hello @AGoryunova 

You are sending a "link" event which would typically not trigger "pageviews" - it would usually be used to monitor clicks, and the user interacting with the page in some way.

If you would like "view" events, you should use "utag.view()" instead

Highlighted

Trigger GUA Tag every 30 seconds

Silver Contributor
Silver Contributor

@LordLingham 

But then it will generate every 30 seconds new page view, what i don't want, as my aim is just to get to know if the user is still there (even when he doesn't click anything) --> adjusted bounce rate. 

So I want that he just generate "event" without page view, but also without new sessions (this is the case now - no page view but new session).

Highlighted

Trigger GUA Tag every 30 seconds

Tealium Employee

@AGoryunova - Sorry it seems i misunderstood your comment.

 

Can you clarify what you mean by "ghost sessions" ?
What ISN'T happening that you would expect to see?

Highlighted

Trigger GUA Tag every 30 seconds

Silver Contributor
Silver Contributor

@LordLingham 

So, the code which i posted, actually works.

BUT: each time when it fires an event, it fires additionaly new session without page view.

Example, users comes and stays at the page 3 minutes (180 seconds) and doesn't click anything.

Should be: 1 Session, 1 Page View.

Actually it is: 7 Sessions (1 Sessions from the entering the page, and 6 sessions for each 30 seconds hit), 1 Page View. --> here we have these "ghost sessions".

 

I hope you understand what i mean.

 

Thank you in advance.

 

Best Regards,

Alexandra

Highlighted

Trigger GUA Tag every 30 seconds

Tealium Employee

@AGoryunova Apologies for the delayed response.

 

Is Ga triggering the additional sessions, or is this sessions within IQ?

If you are happy to message me a URL where i can see this happening, i'd behappy to do a little bit of debugging for you.
Alternatively, if you raise a ticket with support, one of my colleagues or I will be more than happy to have a look!

 

Thanks

James

Trigger GUA Tag every 30 seconds

Silver Contributor
Silver Contributor

Hello @LordLingham ,

 

Thank you for your reply.

It is GA which is triggering the additional sessions.

I think, i will open a ticket by support. Thank you.

Best Regards,

Alexandra