Track campaigns with Google Analytics without query string parameters?

后端 未结 9 1214
忘掉有多难
忘掉有多难 2020-11-30 18:52

Is there a supported way in Google Analytics to track a campaign without having to use query string parameters.

In Analytics you can tag a link to your site with que

9条回答
  •  旧巷少年郎
    2020-11-30 19:34

    I posted this to the Google help forum.

    Google Please Read!!! Great enhancement opportunity!!! This is causing a lot of users not to be able to use the Advertising parameters. Allow the Advertising parameters to be read from the URL used on trackPageview(url).

    In any case, without this capability, I had to use a work-around. Rather than appending the parameters to the URL. I temporarily appended them to the URL as a bookmark. Then I removed them after the trackPageview call. By adding them as a bookmark, the page is no reloaded. See the following example.

    var pageTracker = _gat._getTracker(param);
    var orighash = document.location.hash;
    if (orighash == "") {
        orighash = "none";  // this is done to prevent page scrolling
    }
    document.location.hash = 'utm_source='+source+'&utm_campaign='+campaign+'&utm_medium='+medium+'&utm_content='+content;
    pageTracker._setAllowAnchor(true);
    pageTracker._trackPageview();
    document.location.hash = orighash
    

提交回复
热议问题