Announcement

Collapse
No announcement yet.

9.6 Analytics "price" field question

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    9.6 Analytics "price" field question

    Is there a way for the "price" variable in the new GA tracking code to pull the "cost" field instead of price?

    Not the end of the world if this isn't possible, but it would be nice to take advantage of this new code now that it works with URI's!
    Dylan Buchfink
    The Mattress & Sleep Company
    http://www.tmasc.ca/

    #2
    Yes. All the GA code is editable and can be modified. Once installed, go to utilities and the Google Analytics Tracking Code Tab. Here you can switch to advanced mode and change that data gets sent to GA for the price field:


    Code:
    <mvt:foreach iterator="ga_orderitem" array="ga_tracking:orderitems">
        ga( 'ec:addProduct', {
            'id'        : '<mvt:item name="ga_jsencode" param="ga_orderitem:code_unencoded" />',
            'name'        : '<mvt:item name="ga_jsencode" param="ga_orderitem:name_unencoded" />',
            'price'        : '<mvt:item name="ga_jsencode" param="ga_orderitem:price" />',
            'variant'    : '<mvt:item name="ga_jsencode" param="ga_orderitem:variant_label_unencoded" />',
            'quantity'     : '<mvt:eval expr="l.settings:ga_orderitem:quantity" />'
        } );
        </mvt:foreach>
    should be able to be changed to:

    Code:
    <mvt:foreach iterator="ga_orderitem" array="ga_tracking:orderitems">
    ga( 'ec:addProduct', {
    'id' : '<mvt:item name="ga_jsencode" param="ga_orderitem:code_unencoded" />',
    'name' : '<mvt:item name="ga_jsencode" param="ga_orderitem:name_unencoded" />',
    'price' : '<mvt:item name="ga_jsencode" param="ga_orderitem:cost" />',
    'variant' : '<mvt:item name="ga_jsencode" param="ga_orderitem:variant_label_unencoded" />',
    'quantity' : '<mvt:eval expr="l.settings:ga_orderitem:quantity" />'
    } );
    </mvt:foreach>
    Brennan Heyde
    VP Product
    Miva, Inc.
    [email protected]
    https://www.miva.com

    Comment


      #3
      Hi Brennan -
      I posted a similar question earlier. I would like the revenue reported for a given order to reflect the order subtotal, instead of the grand total which includes shipping, etc. What param can be used to capture that figure in place of "ga_tracking:order_total"?

      Thanks,
      Paul
      Paul

      Comment


        #4
        You should be able to use the order:subtotal variable but it is not part of the ga_tracking structure so it would look like this:

        Code:
        ga( 'ec:setAction', 'purchase', {
                'id'             : '<mvt:eval expr="int( l.settings:ga_orderitem:order_id )" />',
                'revenue'         : '&mvtj:order:subtotal;',
                'affiliation'    : '<mvt:item name="ga_jsencode" param="store:name" />',
                'tax'            : '<mvt:item name="ga_jsencode" param="ga_tracking:total_tax" />',
                'shipping'        : '<mvt:item name="ga_jsencode" param="ga_tracking:total_ship" />'
            } );
        Brennan Heyde
        VP Product
        Miva, Inc.
        [email protected]
        https://www.miva.com

        Comment


          #5
          Thanks. That did the trick. I had tried it before without the "j" version of "&mvt" and it didn't work.
          Paul

          Comment

          Working...
          X