Track campaigns with Google Analytics without query string parameters?

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

    Török Gábor gave me an idea.

    // ...
    var campaignMedium = <%= ViewData.Model.CampaignMedium %>;
    var campaignSource = <%= ViewData.Model.CampaignSource %>;
    var campaignName = <%= ViewData.Model.CampaignName %>;
    
    // save the old hash
    var oldHash = document.location.hash;
    
    // add campaign data to the hash
    document.location.hash = 'utm_source=' + escape(campaignSource) + ...;
    pageTracker._setAllowAnchor(true);
    pageTracker._trackPageview();
    // restore the old hash:
    document.location.hash = oldHash;
    

    This way, you could create the campaign data in the backend, and then, pass it to the hash dynamically, and then restore it without user even noticing it. I.e. the campaign tracking is 100% independent of the real URL.

提交回复
热议问题