2

I've run into an interesting scenario in Google Analytics that I was able to discover using the User Explorer report.

This user came to a page and then let it sit for an hour which caused the Google Analytics session to timeout. When they were active again, they did not reload the page. Instead they triggered a few events and eventually filled out a form which triggered a goal conversion and then redirected them to a "Thank You" page.

What happened is now the Thank You page was considered the landing page, and the goal completion location is set as "(entrance)".

Here is a screenshot of the User Explorer report. I've organized it so it is in chronological order top to bottom.

GA User Explorer Report

Since the "Thank You" page is the first pageview after the session timeout, it is associated with everything. I'm sure I could alter this with different attribution modeling, but I'd like to consider alternate ideas that I could do in code- I'm thinking maybe I can send the window.location in the fieldsObject of my ga('send', 'event'... function?

Any other thoughts?

1

What I came up with to help this is a custom Google Analytics Task that listens for events and makes sure the payload contains a page location and title.

//Modify the payload if needed before sending data to Google Analytics
ga(function(tracker){
    var originalSendHitTask = tracker.get('sendHitTask'); //Grab a reference to the default sendHitTask function.

    tracker.set('sendHitTask', function(model){
        //Always make sure events have the page location and title associated with them (in case of session timout)
        if ( model.get('hitType') === 'event' ){
            if ( !model.get('location') ){
                tracker.send('pageview'); //Send a new pageview if the event does not have contextual data.
            }
        }

        originalSendHitTask(model); //Send the payload to Google Analytics
    });
});

This won't update all field values (which would be nice) like a pageview would, so I've thought about checking if the location is empty and if so sending a new pageview first and then the event...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.