Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Managing Campaign Analytics Scripts

Managing Campaign Analytics Scripts

System_CLiX_warning Warning

This feature has been deprecated and the content on this page will not be refreshed as of October 2014. Instead please see Managing Tags With Universal Event Tracking (UET).

This feature is set to be removed in the next version of the API.

Any goal scripts that contain flex.atdmt are no longer supported. This string is found in goals created prior to July 2013.

Any goal scripts that contain flex.msn will continue to work.

New scripts or editing existing scripts is no longer available.

Use analytics to track campaign performance and optimize your campaigns. For accounts that are setup to use Bing Ads Campaign Analytics, you can do the following:

  • Track conversions and user completion of your goal.

  • Track the user’s steps that led from an ad click to conversion.

  • Capture the revenue and costs, if any are associated with the conversion.

System_CLiX_note Note

Campaign analytics does not track user location or demographics. For such performance history you can submit either GeographicalLocationReportRequest or AgeGenderDemographicReportRequest with the Reporting service. For more information, see Getting Reports.

Campaign Analytics requires that your website supports JavaScript and that the user’s computer allows cookies. When a user clicks your ad and navigates to your website’s landing page, a cookie is created that uniquely identifies the clicked ad for the corresponding account. The last ad that brought the user to the website will get credit for the conversion. Any ad in the same account that was clicked previously during the conversion period will get credit for an assist.

For an example use case with Campaign Analytics, see Tracking sales after the click - Understanding Conversions. For information on set up, reports, and troubleshooting, see the following sections.

Enable and Setup Campaign Analytics

For information on enabling campaign analytics with the Bing Ads web application, see Use campaign analytics to track site activity.

When you create a goal in the Bing Ads web application and click Save and Generate Code, you will be provisioned with a script similar to the following.

<script type="text/javascript"> 
    if (!window.mstag) 
        mstag = {loadTag : function(){},time : (new Date()).getTime()};
</script> 

<script id="mstag_tops" type="text/javascript" src="//flex.msn.com/mstag/site/AccountProvisionedGUID/mstag.js">
</script> 

<script type="text/javascript"> 
    mstag.loadTag(
        "analytics", 
        {dedup:"1",
        domainId:"ProvisionedAccountId",
        type:"1",taxcost:"",
        shippingcost:"",
        nonadvertisingcost:"",
        revenue:"",actionid:"StepProvisionedActionId"})
</script> 

<noscript> 
    <iframe src="//flex.msn.com/mstag/tag/AccountProvisionedGUID/analytics.html?dedup=1&domainId=ProvisionedAccountId&type=1&taxcost=&shippingcost=&nonadvertisingcost=&revenue=&actionid=StepProvisionedActionId" frameborder="0" scrolling="no" width="1" height="1" style="visibility:hidden;display:none"> 
    </iframe>
</noscript>

The script contains the following notable parameter values, some of which are configurable.

Parameter

Description

Configurable

Required

actionid

Provisioned when you create a goal, this value uniquely identifies each step.

You should not modify the provided value. You must use a provisioned value for a step that is not deleted, as otherwise the step will not be tracked. Also note that even a valid actionid cannot be substituted within the script belonging to a different account.

No

Yes

dedup

Used to de-duplicate multiple conversions by the same user during the advertiser defined conversion period. Possible values are 1, 2, and 3, and the default value provisioned with a new goal is 1. For more information, see Setting the dedup Parameter below.

If the dedup value is removed or set to an unsupported value, then no action is taken to de-duplicate the conversions counted. Effectively that is the equivalent of setting dedup to 3.

Yes

No

domainId

The same value as the Id element of the Account.

No

Yes

nonadvertisingcost

You can use this parameter to send information about non-advertising costs that you want to track. Bing Ads will keep track of this data and is available for you to get with the Reporting service. For more information, see Including Costs in the Conversion Data and Get Reports below.

Yes

No

revenue

You can use this parameter to send information about revenue that you want to track. Bing Ads will keep track of this data and is available for you to get with the Reporting service. For more information, see Fixed Revenue Model, Variable Revenue Model, and Get Reports below.

Yes

No

shippingcost

You can use this parameter to send information about shipping costs that you want to track. Bing Ads will keep track of this data and is available for you to get with the Reporting service. For more information, see Including Costs in the Conversion Data and Get Reports below.

Yes

No

taxcost

You can use this parameter to send information about tax costs that you want to track. Bing Ads will keep track of this data and is available for you to get with the Reporting service. For more information, see Including Costs in the Conversion Data and Get Reports below.

Yes

No

type

Reserved for internal use.

No

Yes

You do not need to alter the scripts for the landing page, browse pages, and prospect pages. However, for the conversion script, you may need to update the script depending on the revenue model that you use (fixed or variable) and whether you capture cost data, such as sales tax and shipping fees, in the conversion data.

System_CLiX_noteNote

Revenue and costs are not tracked for Land, Browse, or Prospect steps. If you specify such values in steps other than a Conversion step they will be ignored by Bing Ads.

For details about changes that you might want or need to make to your revenue conversion script, see the following sections:

Setting the dedup Parameter

If a user clicks an ad, goes to your website, purchases an item, returns to your website within the conversion period, and then purchases another item, the dedup parameter determines whether to count one conversion for the click or count each conversion for the click.

The following are the possible values:

  • 1 — Count only one conversion for the click regardless of the number of conversions that the user made during the conversion period.

  • 2 — Count one conversion per unique referring URL. The referring URL is the URL of the web page with your published script.

  • 3 — Count all conversions for the click made by the user during the conversion period.

If you set dedup to 2 or 3, the conversion report can show a higher number of conversions compared to the number of clicks.

<script type="text/javascript">
    mstag.loadTag(
        "analytics", 
        { dedup: "1", domainId: "XXXXXX", type: "1", revenue: "<REVENUEVALUEGOESHERE>", actionid: "XXXX" }
        )
</script>

<noscript>
    <iframe src="//flex.msn.com/mstag/tag/<Bing Ads-defined GUID Provisioned Here>/analytics.html?dedup=1&domainId=XXXXXX&type=1&revenue=<REVENUEVALUEGOESHERE>&actionid=XXXX"
            frameborder="0" scrolling="no" width="1" height="1" style="visibility: hidden; display: none">
    </iframe>
</noscript>

Fixed Revenue Model

The following shows an example of a script for a conversion step that uses the fixed revenue model. The generated script does not include the revenue parameter in the loadTag call. You must include the revenue parameter and specify its fixed value. The example shows only the script elements that you place in the <body> section of your web page. For more information, see Place the Script on your web page.


<script type="text/javascript">
    mstag.loadTag(
        "analytics", 
        { dedup: "1", domainId: "XXXXXX", type: "1", revenue: "<REVENUEVALUEGOESHERE>", actionid: "XXXX" }
        )
</script>

<noscript>
    <iframe src="//flex.msn.com/mstag/tag/<Bing Ads-defined GUID Provisioned Here>/analytics.html?dedup=1&domainId=XXXXXX&type=1&revenue=<REVENUEVALUEGOESHERE>&actionid=XXXX"
            frameborder="0" scrolling="no" width="1" height="1" style="visibility: hidden; display: none">
    </iframe>
</noscript>

Variable Revenue Model

The following shows an example of a script for a conversion step that uses the variable revenue model. You must add a JavaScript function or script variable that provides the revenue value for the conversion. This example uses a function named getRevenue to provide the revenue value.

For the <noscript> element, the server that serves the web page will need to dynamically generate the source URL in order to include the revenue value before loading the page.

The example shows only the script elements that you place in the <body> section of your web page (see Place the Script on your web page).

<script type="text/javascript">
    // An example function that returns
    // the revenue value for the conversion.
    
    function getRevenue() {
        // Replace the content of this function with your own code
        // that returns the revenue value.
        
        return Math.ceil(Math.random() * 10);
    }
</script>

<script type="text/javascript">
    mstag.loadTag(
        "analytics", 
        { dedup: "1", domainId: "XXXXXX", type: "1", revenue: getRevenue(), actionid: "XXXX" }
        )
</script>

<noscript>
    <iframe src="//flex.msn.com/mstag/tag/<Bing Ads-defined GUID Provisioned Here>/analytics.html?dedup=1&domainId=XXXXXX&type=1&revenue=&actionid=XXXX"
            frameborder="0" scrolling="no" width="1" height="1" style="visibility: hidden; display: none">
    </iframe>
</noscript>

Including Costs in the Conversion Data

If you chose to capture costs—such as sales tax, shipping fees, or other costs—the script will include parameters for these cost items. You must update the script to specify the values of these cost items. If the costs are fixed, you can specify a constant value for each item. Otherwise, you must provide a function that returns the cost value.

The following example shows how to set the sales tax and shipping fees cost parameters when the values are fixed. The parameter name that is used to capture other costs is nonadvertisingcost. The example shows only the script elements that you place in the <body> section of your web page. For more information, see Place the Script on your web page.


<script type="text/javascript">
    mstag.loadTag(
        "analytics", 
        { dedup: "1", domainId: "XXXXXX", type: "1", taxcost: "<SALESTAXVALUEGOESHERE>", shippingcost: "<SHIPPINGFEEVALUEGOESHERE>", revenue: "<REVENUEVALUEGOESHERE>", actionid: "XXXX" }
        )
</script>

<noscript>
    <iframe src="//flex.msn.com/mstag/tag/<Bing Ads-defined GUID Provisioned Here>/analytics.html?dedup=1&domainId=XXXXXX&type=1&taxcost=<SALESTAXVALUEGOESHERE>&shippingcost=<SHIPPINGFEEVALUEGOESHERE>&revenue=<REVENUEVALUEGOESHERE>&actionid=XXXX"
            frameborder="0" scrolling="no" width="1" height="1" style="visibility: hidden; display: none">
    </iframe>
</noscript>

The following example shows how to set the sales tax and shipping fees cost parameters when the values are variable. You must add a JavaScript function or script variables that provide the tax and shipping fee values for the conversion.

For the <noscript> element, the server that serves the web page will need to dynamically generate the source URL in order to include the revenue and cost values before loading the page.

<script type="text/javascript">
    // An example function that returns
    // the revenue value of the conversion.

    function getRevenue() {
        // Replace the content of this function with your own code
        // that returns the revenue value.

        return Math.ceil(Math.random() * 10);
    }

    // An example function that returns
    // the sale tax value of the conversion.

    function getSalesTax() {
        // Replace the content of this function with your own code
        // that returns the revenue value.

        return Math.ceil(Math.random() * 10);
    }

    // An example function that returns
    // the shipping fee value of the conversion.

    function getShippingFee() {
        // Replace the content of this function with your own code
        // that returns the revenue value.

        return Math.ceil(Math.random() * 10);
    }
</script>

<script type="text/javascript">
    mstag.loadTag(
        "analytics", 
        { dedup: "1", domainId: "XXXXXX", type: "1", taxcost: getSalesTax(), shippingcost: getShippingFee(), revenue: getRevenue(), actionid: "XXXX" }
        )
</script>

<noscript>
    <iframe src="//flex.msn.com/mstag/tag/<Bing Ads-defined GUID Provisioned Here>/analytics.html?dedup=1&domainId=XXXXXX&type=1&taxcost=&shippingcost=&revenue=&actionid=XXXX"
            frameborder="0" scrolling="no" width="1" height="1" style="visibility: hidden; display: none">
    </iframe>
</noscript>

Place the Script on your web page

Place the following elements of the script in the <body> section of the web page near the closing tag.

<script type="text/javascript">
    if (!window.mstag) mstag = { loadTag: function () { }, time: (new Date()).getTime() };
</script>

<script id="mstag_tops" type="text/javascript" 
    src="//flex.msn.com/mstag/site/<Bing Ads-defined GUID Provisioned Here>/mstag.js">
</script>

<script type="text/javascript">
    mstag.loadTag(
        "analytics", 
        { dedup: "1", domainId: "XXXXXX", type: "1", revenue: "<REVENUEVALUEGOESHERE>", actionid: "XXXX" }
        )
</script>

<noscript>
    <iframe src="//flex.msn.com/mstag/tag/<Bing Ads-defined GUID Provisioned Here>/analytics.html?dedup=1&domainId=XXXXXX&type=1&revenue=&actionid=XXXX"
            frameborder="0" scrolling="no" width="1" height="1" style="visibility: hidden; display: none">
    </iframe>
</noscript>

The following two elements from the above code send the information to Bing Ads. The browser determines whether the <script> or <noscript> code sends the information. If the browser supports JavaScript, the <script> element sends the data; otherwise, the <noscript> element sends the data.

<script type="text/javascript">
    mstag.loadTag(
        "analytics", 
        { dedup: "1", domainId: "XXXXXX", type: "1", revenue: "<REVENUEVALUEGOESHERE>", actionid: "XXXX" }
        )
</script>

<noscript>
    <iframe src="//flex.msn.com/mstag/tag/<Bing Ads-defined GUID Provisioned Here>/analytics.html?dedup=1&domainId=XXXXXX&type=1&revenue=&actionid=XXXX"
            frameborder="0" scrolling="no" width="1" height="1" style="visibility: hidden; display: none">
    </iframe>
</noscript>

A web page can contain the analytics scripts from only one account. If the account defines multiple goals, the web page can contain the scripts of one or more of the goals. However, the web page must include only one occurrence of the following script elements that you copy from the script of one of the goals.

<script type="text/javascript">
    if (!window.mstag) mstag = { loadTag: function () { }, time: (new Date()).getTime() };
</script>

<script id="mstag_tops" type="text/javascript" 
    src="//flex.msn.com/mstag/site/<Bing Ads-defined GUID Provisioned Here>/mstag.js">
</script>

Get Reports

You can use the Reporting service to analyze the data that Campaign Analytics captures. For example you can use the following report request types. For more information, see Getting Reports.

Issues to Avoid

The following should be avoided when coding your web pages that include an analytics script.

  • The use of jQuery or other such mechanisms for loading the scripts, because some implementations may execute scripts out of order or otherwise interfere with the Bing Ads campaign analytics pipeline.

  • The use of the <base> element because it may cause a message to display to the user that indicates that the page is loading an unsecure script. This can happen if the protocol for your website uses HTTPS and you use the <base> element to load a web page using the HTTP protocol. Because the analytics scripts do not use an explicit protocol for the source URI, they will attempt to load by using HTTP instead of HTTPS, which will generate the message.

Troubleshoot Deployed Scripts

The following steps may help troubleshoot campaign analytics issues, for example no conversions or revenue being tracked.

  1. Verify that campaign analytics is enabled for the account. In the Bing Ads web application, go to Tools - Campaign Analytics.

  2. Confirm that your ad is delivered by using one of your keywords as a search query.

  3. With your mouse or other pointing device, hover over the delivered ad or right-click and copy the redirect URL. The URL should be of the form http://x.r.msn.com, where x is your account identifier. If the URL is http://0.r.msn.com then campaign analytics is not enabled for the account of the ad that was delivered by your search query.

  4. Run a tool to capture network traffic, for example Fiddler.

  5. Click on the ad and navigate your web site to step through a test conversion.

  6. After your conversion page has loaded, inspect the network trace. You should observe one or more calls to host flex.msn.com, and finally a call to host x.r.msn.com where x is the value of your account identifier and corresponds to your script's domainid. The URL should also contain parameters representing the conversion, action identifier, and revenue or shipping if specified in your script. For example, /?type=1&domainId=<accountid>&dedup=1&actionid=<actionid>&revenue=<revenuefromscript>.

Community Additions

ADD
Show:
© 2015 Microsoft