Track campaigns with Google Analytics without query string parameters?

后端 未结 9 1183
忘掉有多难
忘掉有多难 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:29

    You can use the Google Analytics API to customize the call to _trackPageview in your example.

    pageTracker._trackPageview("/inbound/" + campaignSource + "/" + campaignMedium );
    

    All of the inbound links will then show up in Google Analytics under the /inbound/ "pseudo directory" with a separate "directory" for Campaign Source and Campaign Medium.

    0 讨论(0)
  • 2020-11-30 19:34

    The solution using push(['_set', 'campaignParams',... seems only to work for the legacy library ga.js.

    Using analytics.js you need to specify the campaign param separately. E.g.

    ga('set', 'campaignName', 'TheCampaignName...');
    ga('set', 'campaignSource', 'someCampaignSource');
    ga('set', 'campaignMedium', 'email');
    

    https://developers.google.com/analytics/devguides/collection/analyticsjs/field-reference#campaignName

    0 讨论(0)
  • 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
    
    0 讨论(0)
提交回复
热议问题