简体   繁体   中英

This code tracks JQM page in GA. How can I track the page plus the query parameter?

I found this code which tracks pages but I have query parameters too.

For example, my url may look like page.html#one?d=firstparam&n=secondparam

This code tracks the page but I lose the query parameter:

$(document).on('pageshow', '[data-role=page], [data-role=dialog]', function (event, ui) {
    try {
        if ($.mobile.activePage.attr("data-url")) {
            ga('send', 'pageview', $.mobile.activePage.attr("data-url"));         // remove quotes
        } else {
            ga('send', 'pageview');
        }
    } catch (err) {}
});

The code is from this post: jQuery Mobile Google Universal Analytics

GA will display the page like one but I lose the page.html and the query bits.

No code changes (standard GA tracking) gives me page.html and nothing else.

How can I get the whole: page.html#one?d=firstparam&n=secondparam ?

You can try to follow this resource . Basically you will need to overwrite the default page by rebuilding it with the information you need when you send the pageview hit. Be aware that there have been issues, as exposed in this SO post

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM