Page 1 of 1

More Conversion Tracking

Posted: Mon Aug 15, 2016 2:47 pm
by kwikstand
I am now attempting to get conversion tracking for AdRoll working. I have it working for Google Conversion, so I imagine it should be similar.

The AdRoll code is below. Down near the bottom is a line: adroll_conversion_value = X; What needs to be used in place of X?

[code<!-- AdRoll Code -->
<script type="text/javascript">
adroll_adv_id = "XXXXXXXXX";
adroll_pix_id = "XXXXXXXXXX";
(function () {
var oldonload = window.onload;
window.onload = function(){
__adroll_loaded=true;
var scr = document.createElement("script");
var host = (("https:" == document.location.protocol) ? "https://s.adroll.com" : "http://a.adroll.com");
scr.setAttribute('async', 'true');
scr.type = "text/javascript";
scr.src = host + "/j/roundtrip.js";
((document.getElementsByTagName('head') || [null])[0] ||
document.getElementsByTagName('script')[0].parentNode).appendChild(scr);
if(oldonload){oldonload()}};
}());
</script>
<script type="text/javascript">
adroll_conversion_value = X;
adroll_currency = "USD"
</script>
][/code]

Any help would be appreciated,

Re: More Conversion Tracking

Posted: Tue Aug 16, 2016 5:33 am
by Katie
I'm not familiar with Adroll. Do they offer support or documentation for their code?

Re: More Conversion Tracking

Posted: Tue Aug 16, 2016 7:32 am
by kwikstand
Will this help? https://help.adroll.com/hc/en-us/articl ... n-Tracking This is for conversion tracking.
It would be great if it could serve up dynamic ads as well, like I have been trying with Google Remarketing. I have been tinkering with Adroll a little and so far I like it better than Google. Adroll has the ability of using emails from your CRM to target customers on the web AND Facebook. That's right, you can run ads on Facebook with AdRoll. You can also use it to target abandoned carts, I just wish I could send those emails dynamically with the product that was in the cart on display rather than a generic ad. It has the capability, but I can't get it to work with AC. So far, I have been getting many more impressions and a much higher CTR and a much lower CPC than I do with Google.

Since we are on this subject, I might ad that MailChimp has a lot of functionality as well. It would be nice if it could be integrated with AC. Just food for thought as you work on the next upgrade.

Re: More Conversion Tracking

Posted: Tue Aug 16, 2016 8:35 am
by Shopping Cart Admin
Hello,

In /conlib/ConversionTracking.ascx I found the values we use for google conversions, you should be able to add the adroll stuff into this file.

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ConversionTracking.ascx.cs" Inherits="AbleCommerce.ConLib.ConversionTracking" %>
<script runat="server">
decimal TotalValue { get; set; }
string Currency { get; set; }
protected void Page_PreRender(object sender, EventArgs e)
{
CommerceBuilder.Orders.Order order = OrderDataSource.Load(AbleCommerce.Code.PageHelper.GetOrderId());
TotalValue = order.ProductSubtotal;
Currency = CommerceBuilder.Common.AbleContext.Current.Store.BaseCurrency.ISOCode;
}
</script>
<!-- Google Code for test Conversion Page -->
<script type="text/javascript">
/* <![CDATA[ */
var google_conversion_id = 1072638847;
var google_conversion_language = "en";
var google_conversion_format = "3";
var google_conversion_color = "ffffff"
var google_conversion_label = "o1i1CJXA2GEQ_9a8_wM";
var google_conversion_value = <%= TotalValue%>;
var google_conversion_currency = <%= Currency%>;
var google_remarketing_only = false;
/* ]]> */
</script>
<script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js">
</script>
<noscript>
<div style="display:inline;">
<img height="1" width="1" style="border-style:none;" alt="" src="//www.googleadservices.com/pagead/convers ... 47/?value=<%= TotalValue%>&currency_code=<%= Currency%>&label=o1i1CJXA2GEQ_9a8_wM&guid=ON&script=0"/>
</div>
</noscript>

Re: More Conversion Tracking

Posted: Wed Aug 17, 2016 3:40 am
by nadeem
Down near the bottom is a line: adroll_conversion_value = X; What needs to be used in place of X?
X is the total value that will be the product subtotal which you will get from the order using the code above.

Re: More Conversion Tracking

Posted: Wed Aug 17, 2016 11:45 am
by kwikstand
Thanks for looking into it. I already tried fiddling around using the variable from /conlib/ConversionTracking.ascx in the adroll code but it didn't work. It broke my site., What do you mean by
you should be able to add the adroll stuff into this file
?

Re: More Conversion Tracking

Posted: Wed Aug 17, 2016 11:51 am
by Shopping Cart Admin
Should work by adding this to the conversion tracking page.

<!-- AdRoll Code -->
<script type="text/javascript">
adroll_adv_id = "XXXXXXXXX";
adroll_pix_id = "XXXXXXXXXX";
(function () {
var oldonload = window.onload;
window.onload = function(){
__adroll_loaded=true;
var scr = document.createElement("script");
var host = (("https:" == document.location.protocol) ? "https://s.adroll.com" : "http://a.adroll.com");
scr.setAttribute('async', 'true');
scr.type = "text/javascript";
scr.src = host + "/j/roundtrip.js";
((document.getElementsByTagName('head') || [null])[0] ||
document.getElementsByTagName('script')[0].parentNode).appendChild(scr);
if(oldonload){oldonload()}};
}());
</script>
<script type="text/javascript">
adroll_conversion_value = <%= TotalValue%>;
adroll_currency = "USD"
</script>

Re: More Conversion Tracking

Posted: Wed Aug 17, 2016 3:00 pm
by kwikstand
Thank a lot. That seems to work, except that I already have that code in the /ConLib/StoreFooter.ascx because it needs to be on every page. Previously, I was trying to put <%= TotalValue%>; there, in the footer. That's when the site broke.
Putting it in the ConversionTracking.ascx works, but now I have code in both places, so I put just the last part in ConversionTracking.ascx:

Code: Select all

<script type="text/javascript">
  adroll_conversion_value = <%= TotalValue%>;
  adroll_currency = "USD"
</script>
and I kept all the rest of the code in the footer. Does this make sense? Will all of the AdRoll code work properly being broken up like that?

Thanks

Re: More Conversion Tracking

Posted: Fri Aug 19, 2016 3:22 am
by nadeem
except that I already have that code in the /ConLib/StoreFooter.ascx because it needs to be on every page.
Why are you putting this code on every page? Isn't this go to the order receipt page? TotalValue in above code is the product subtotal in an order. You can't get this value before order placement. If you try to use this code in store footer (to be used on all pages), it will got broken.

Let me know if you still want to place this code on every page. I will provide you the updated code with fix conversion value for all other pages except receipt page so that it won't be broken.

Re: More Conversion Tracking

Posted: Fri Aug 19, 2016 3:48 am
by kwikstand
The adroll code is not just for conversion vale. AdRoll is a Remarketing platform. It needs to be put on all pages to track which pages the user views. Among other things, it can be used to dynamically serve ads relevant to the user, like products they already viewed.

https://help.adroll.com/hc/en-us/articles/211846018

Re: More Conversion Tracking

Posted: Fri Aug 19, 2016 4:28 am
by nadeem
Got it. You aren't using adroll code only to track conversion value but remarketing in general. The total value in above code is obtained from order subtotal.

Re: More Conversion Tracking

Posted: Fri Aug 19, 2016 5:25 am
by kwikstand
Yes, I know. My question now is, since I had to break the AdRoll code up, will it still function properly. (please read above) When I put the conversion portion in the StoreFooter.ascx, it broke the website. I had to put it in the ConversionTracking.ascx The rest of the AdRoll code, I kept in the StoreFooter.ascx

So, I put

Code: Select all

<!-- AdRoll Code -->
<script type="text/javascript">
adroll_adv_id = "XXXXXXXXX";
adroll_pix_id = "XXXXXXXXXX";
(function () {
var oldonload = window.onload;
window.onload = function(){
__adroll_loaded=true;
var scr = document.createElement("script");
var host = (("https:" == document.location.protocol) ? "https://s.adroll.com" : "http://a.adroll.com");
scr.setAttribute('async', 'true');
scr.type = "text/javascript";
scr.src = host + "/j/roundtrip.js";
((document.getElementsByTagName('head') || [null])[0] ||
document.getElementsByTagName('script')[0].parentNode).appendChild(scr);
if(oldonload){oldonload()}};
}());
</script>
in the ConversionTracking.ascx

and this

Code: Select all

<script type="text/javascript">
  adroll_conversion_value = <%= TotalValue%>;
  adroll_currency = "USD"
</script>
in the StoreFooter.ascx file

I don't know why the website breaks when I pout those few lines in the StoreFooter.ascx

Re: More Conversion Tracking

Posted: Fri Aug 19, 2016 5:41 am
by nadeem
No. It will not work this way. To make it working correctly put together all the code in store footer.

First find the following line at top inside StoreFooter.ascx :

Code: Select all

<%@ Control Language="C#" AutoEventWireup="True" CodeFile="StoreFooter.ascx.cs" Inherits="AbleCommerce.ConLib.StoreFooter" %>
and replace with

Code: Select all

<%@ Control Language="C#" AutoEventWireup="True" CodeFile="StoreFooter.ascx.cs" Inherits="AbleCommerce.ConLib.StoreFooter" %>
<script runat="server">
    decimal TotalValue { get; set; }
    protected void Page_PreRender(object sender, EventArgs e)
    {
        CommerceBuilder.Orders.Order order = OrderDataSource.Load(AbleCommerce.Code.PageHelper.GetOrderId());
        if (order != null)
            TotalValue = order.ProductSubtotal;
        else
            TotalValue = 20; // Some fix value if it ins't an order page
    }
</script>
Note that I have hard-coded the total value when order is null i.e. other than order page.

After this, add the adroll code to your desired location in store footer. For example, below GoogleAnalyticsWidget something like this:

Code: Select all

<!-- AdRoll Code -->
<script type="text/javascript">
adroll_adv_id = "XXXXXXXXX";
adroll_pix_id = "XXXXXXXXXX";
(function () {
var oldonload = window.onload;
window.onload = function(){
__adroll_loaded=true;
var scr = document.createElement("script");
var host = (("https:" == document.location.protocol) ? "https://s.adroll.com" : "http://a.adroll.com");
scr.setAttribute('async', 'true');
scr.type = "text/javascript";
scr.src = host + "/j/roundtrip.js";
((document.getElementsByTagName('head') || [null])[0] ||
document.getElementsByTagName('script')[0].parentNode).appendChild(scr);
if(oldonload){oldonload()}};
}());
</script>
<script type="text/javascript">
adroll_conversion_value = <%= TotalValue%>;
adroll_currency = "USD"
</script>

Re: More Conversion Tracking

Posted: Fri Aug 19, 2016 6:37 am
by kwikstand
OK. I will try it later this evening.

Won't using an arbitrary number for TotalValue skew the analytics? For example, will it record the $20 for all the other pages that are viewed?

Re: More Conversion Tracking

Posted: Fri Aug 19, 2016 4:01 pm
by kwikstand
OK, Nadeem, I think I have it working now. My site doesn't crash and I can see the subtotal value on a receipts.aspx page. I made the arbitrary value 0, instead of $20. I will now wait for an actual conversion from an AdRoll ad to see it work. Thank you very much your help is greatly appreciated.

Do you happen to know how to get the values for Google remarketing? Here is their code:

Code: Select all

<script type="text/javascript">
var google_tag_params = {
ecomm_prodid: "REPLACE_WITH_STRING_VALUE",
ecomm_pagetype: "REPLACE_WITH_STRING_VALUE",
ecomm_totalvalue: REPLACE_WITH_STRING_VALUE
};
</script>
Here are their instructions: https://support.google.com/adwords/answer/3103357

Thanks again Nadeem

Re: More Conversion Tracking

Posted: Sun Aug 21, 2016 11:37 pm
by jmestep
When I did our remarketing plugin, I got the page type from the url most of the time- basket.aspx is a page type of "cart" . I got the product ids based on what the page type it was- cart, order, etc. Same thing with the ecomm value.

Re: More Conversion Tracking

Posted: Wed Aug 24, 2016 3:24 am
by nadeem
As suggested by Judy above, you can get the page type and product ids from the current page URL. According to the google, the page types are home, searchresults, category, product, cart, purchase, other.

Here is the example code that is used to collect data from product pages. Create a new .ascx control (e.g. Remarketing.ascx and put the following code:

Code: Select all

<script runat="server">
    int ProductId { get; set;}
    decimal Price { get; set;}
    protected void Page_PreRender(object sender, EventArgs e)
    {
        CommerceBuilder.Products.Product product = CommerceBuilder.Products.ProductDataSource.Load(AbleCommerce.Code.PageHelper.GetProductId());
        if (product != null )
        {
            ProductId = product.Id;
            Price = product.Price;
        }
    }
</script>
<script type="text/javascript" lanugage="javascript">
var google_tag_params = {
ecomm_prodid: '<%=ProductId%>',
ecomm_pagetype: 'product',
ecomm_totalvalue: '<%=Price%>'
};
</script>
<script type="text/javascript">
/* <![CDATA[ */
var google_conversion_id = xxxxxxxx;
var google_custom_params = window.google_tag_params;
var google_remarketing_only = true;
/* ]]> */
</script>
<script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js">
</script>
<noscript>
<div style="display:inline;">
<img height="1" width="1" style="border-style:none;" alt="" src="//googleads.g.doubleclick.net/pagead/viewthroughconversion/xxxxxxxx/?value=0&guid=ON&script=0"/>
</div>
</noscript>

Now place the new Remarketing.ascx control to your desired location say footer.ascx similar to GoogleAnalyticsWidget widget. Don't forget to replace the original conversion id with xxxxxxxx. Again the above code is only for the 'product' page type. You can use the previous order code for the 'purchase' page type.

Hope this help in moving forward with remarketing plugin.

Re: More Conversion Tracking

Posted: Mon Aug 29, 2016 3:31 pm
by kwikstand
Thanks nadeem.

Are you saying there needs to be different code for each page type? If so, then you can't just put that in the footer because it will be on all pages. For example, the code for a product page will be on category pages, the home page and all the rest.

Re: More Conversion Tracking

Posted: Mon Aug 29, 2016 11:44 pm
by jmestep
You can use the same code for all page types, you just need to put some logic in to determine the page type, then do something with it. Like don't add sections that don't apply. For example, don't output the product info on the search page.

Re: More Conversion Tracking

Posted: Tue Aug 30, 2016 12:38 am
by nadeem
Judy is right, you have to use same code with some updated logic to get each page type. Once you determine the page type, you can set the product ids, price etc. where applicable.

Here is sample of how you can do this:

Code: Select all

<script runat="server">
    string PageType { get; set;} // getter/setter for page type
    int ProductId { get; set;}
    decimal Price { get; set;}
    protected void Page_PreRender(object sender, EventArgs e)
    {
        PageType = "Get the page type from the current URL.";
        if (PageType == "product")
        {
             CommerceBuilder.Products.Product product = CommerceBuilder.Products.ProductDataSource.Load(AbleCommerce.Code.PageHelper.GetProductId());
             if (product != null )
             {
                 ProductId = product.Id;
                 Price = product.Price;
             }
        }
        else if (PageType == "cart")
        {
             // set product id and price for basket item
        }
      // Similarly conditions for other page types and related logic
    }
</script>
After making the above updates you have to change the following line

From

Code: Select all

ecomm_pagetype: 'product'
To

Code: Select all

ecomm_pagetype: '<%=PageType%>',

Re: More Conversion Tracking

Posted: Thu Apr 13, 2017 8:02 am
by xplosi0n1
Hello,

I am trying to change my Google Adsense tracking code from a generic 1 per conversion to the actual conversion value.

I see a conversation about this which was very helpful but I do not have a ConversionTracking.ascx file or the associated .ascx.cs file.

Can someone please supply me with the 2 files.

I also do not know where the below text belongs. Does this go before the google tracking code or was this suppose to be in the ConversionTracking.aspx file?
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ConversionTracking.ascx.cs" Inherits="AbleCommerce.ConLib.ConversionTracking" %>
<script runat="server">
decimal TotalValue { get; set; }
string Currency { get; set; }
protected void Page_PreRender(object sender, EventArgs e)
{
CommerceBuilder.Orders.Order order = OrderDataSource.Load(AbleCommerce.Code.PageHelper.GetOrderId());
TotalValue = order.ProductSubtotal;
Currency = CommerceBuilder.Common.AbleContext.Current.Store.BaseCurrency.ISOCode;
}
</script>
Here is my code for Google Adwords Conversions:

<!-- Google Code for Purchase/Sale Conversion Page -->
<script type="text/javascript">
/* <![CDATA[ */
var google_conversion_id = 1069551680;
var google_conversion_language = "en";
var google_conversion_format = "3";
var google_conversion_color = "666666";
var google_conversion_label = "*****************";
var google_conversion_value = <%= TotalValue%>;
var google_conversion_currency = <%= Currency%>;
var google_remarketing_only = false;
/* ]]> */
</script>
<script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js">
</script>
<noscript>
<div style="display:inline;">
<img height="1" width="1" style="border-style:none;" alt="" src="//www.googleadservices.com/pagead/convers ... 680/?value<%= TotalValue%>&currency_code=<%= Currency%>&label=i68HCOKmXBDAoID-Aw&guid=ON&script=0"/>
</div>
</noscript>

Thank you for your help.
Mike

Re: More Conversion Tracking

Posted: Fri Sep 01, 2017 2:57 pm
by kwikstand
I am at it again. I never was able to get the product id or price returned. Every time I add this code to my footer, it breaks the site:

Code: Select all

<script runat="server">
    int ProductId { get; set;}
    decimal Price { get; set;}
    protected void Page_PreRender(object sender, EventArgs e)
    {
        CommerceBuilder.Products.Product product = CommerceBuilder.Products.ProductDataSource.Load(AbleCommerce.Code.PageHelper.GetProductId());
        if (product != null )
        {
            ProductId = product.Id;
            Price = product.Price;
        }
    }
</script>
I have no problem getting the order total with similar coding. Why can't I get the product ID?