Announcement

Collapse
No announcement yet.

Mailchimp changes affect our conversion tracking

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

    Mailchimp changes affect our conversion tracking

    In order for Mailchimp to track static page click conversion, we were populating all details manually.
    On a static page we were setting cookies mc_cid & mc_eid and on the BASK page we were updating basket with latest MC details.

    Looks like since 9.13.02 the way MC module saves tracking data was changed.

    How do we feed MC data to Miva now?

    Code:
    used to be something like this:
    
    <mvt:if expr="NOT ISNULL g.request_cookies:mc_eid AND NOT ISNULL g.request_cookies:mc_cid">
        <mvt:assign    name="l.settings:basketinfo:basket_id" value="g.basket:basket_id" />
        <mvt:assign    name="l.settings:basketinfo:module_id" value="'227'" />
        <mvt:assign    name="l.settings:basketinfo:type" value="'mailchimp'" />
        <mvt:assign    name="l.settings:basketinfo:clronmod" value="'0'" />
        <mvt:assign    name="l.settings:basketinfo:info:email_address" value="g.customer:pw_email" />
        <mvt:assign    name="l.settings:basketinfo:info:landing_url" value="'MAILCHIMP_LANDING_PAGE.HTML'" />
        <mvt:assign    name="l.settings:basketinfo:info:mc_cid" value="g.request_cookies:mc_cid" />
        <mvt:assign    name="l.settings:basketinfo:info:mc_eid" value="g.request_cookies:mc_eid" />
    
        <mvt:do file="g.Module_Library_DB" name="g.success" value="BasketInfo_Insert(l.settings:basketinfo)" />
        <mvt:if expr="NOT g.success">
            <mvt:do file="g.Module_Library_DB" name="g.success" value="BasketInfo_Update(l.settings:basketinfo)"
            />
        </mvt:if>
    </mvt:if>
    Last edited by AHerb; 08-29-19, 09:26 AM.

    #2
    Uh-oh, will send a request to support

    Comment


      #3
      So this is pretty much what the MailChimp module did in 9.13.02. What was this trying to accomplish? Instead of using global variables for mc_eid / mc_cid, you or someone else set a cookie with those values and then used those cookie values to send to MailChimp? What exactly is going on here? And yes, in 9.13.02 we made changes to the module so it would work better with the deferred baskets options. Storing of that data was moved out of the sNN_BasketInfo table and into a cookie instead.
      David Carver
      Miva, Inc. | Software Developer

      Comment


        #4
        Correct, on the static pages (plain HTML) we did not have an option for any global variables, so Mailchimps' query string variables were stored temporary as cookies and pushed to the basket layer later.

        Now I see that I need to store variables as cookies, which is great. Are we talking about "mm5-STORENAME-mailchimp" cookie? If yes, how do I encrypt values?

        Comment


          #5
          Okay sorry I better understand now. Yes the cookie is mm5-<storecode>-mailchimp and it is base64 encoded in the following format:
          Code:
          <landingurl>:<mc_cid>:<mc_eid>:<email_address>
          So 4 sections of data, all separated by a semi-colon. On the INVC screen we read the cookie, base64 decode and break into the appropriate parts and send it to MailChimp. You probably need to take into account semi-colons existing within any of the individual sections of data when you build the string that you will base64 encode.
          Last edited by dcarver; 09-03-19, 07:12 AM.
          David Carver
          Miva, Inc. | Software Developer

          Comment


            #6
            Any reason why mm5-<storecode>-mailchimp is set as an HttpOnly cookie? If one was already preset I can't modify it with the JavaScript :-/

            UPD: passing params as a different cookie and updating "ServerSideOnly" mm5-<storecode>-mailchimp on a BASK page. Code below

            Thank you, David.
            Last edited by AHerb; 08-30-19, 04:23 PM.

            Comment


              #7
              If someone needs to track static pages with the Mailchimp. For miva 9.13.02+ use following:

              On a static page:
              Code:
              <script type="text/javascript">
              
                  function createCookie(name,value,days) {
                      if (days) {
                          var date = new Date();
                          date.setTime( date.getTime() +(days * 86400 * 1000));
                          var expires = "; expires="+date.toGMTString();
                      }
                      else var expires = "";
                      document.cookie = name+"="+value+expires+"; path=/";
                  }
              
                  function getURLParameter(name) {
                      return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search)||[,""])[1].replace(/\+/g, '%20'))||null;
                  }
                  var url_no_query = window.location.href.split('?')[0].replace(":","\\:");
                  var mailchimpTag = getURLParameter('mc_cid');
                  var mailchimpTag2 = getURLParameter('mc_eid');
                  if (mailchimpTag !== null && mailchimpTag2 !== null) {
                      createCookie('mm5_mailchimp_own', btoa(url_no_query + ':' + mailchimpTag + ':' + mailchimpTag2 + ':' + 'email') , 14);
                  }
              </script>

              On the BASK page:
              Code:
              <mvt:comment>MAILCHIMP TO TRACK EMAIL CAMPAIGNS FROM STATIC PAGES Miva v 9.13.02+</mvt:comment>
              <mvt:if expr="NOT ISNULL g.request_cookies:mm5_mailchimp_own">
                  <mvt:assign name="g.decoded_string" value="crypto_base64_decode(g.request_cookies:mm5_mailchimp_own)" />
              
                  <mvt:if expr="':email' IN g.decoded_string">
                      <mvt:assign name="g.updated_mailchimp_cookie_value" value="glosub( g.decoded_string, ':email', ':' $ g.customer:pw_email )" />
              
                      <mvt:assign name="g.expires"       value="s.time_t + (60 * 60 * 24 * 14)" />
                      <mvt:assign name="g.cookie_name"   value="'mm5-'$ g.store_code $'-mailchimp'" />
                      <mvt:assign name="g.cookie_value"  value="crypto_base64_encode( g.updated_mailchimp_cookie_value )" />
              
                      <mvt:do file="g.module_library_utilities" name="g.null" value="SetCookie(g.Output_Cookies, g.cookie_name, g.cookie_value , g.cookiedomain , g.expires, '/', 0 )" />
                      <mvt:do file="g.module_library_utilities" name="g.null" value="OutputCookies( g.Output_Cookies )" />
              
                      <mvt:assign name="g.expires"       value="s.time_t - 86400" />
                      <mvt:assign name="g.cookie_name"   value="'mm5_mailchimp_own'" />
                      <mvt:assign name="g.cookie_value"  value="''" />
                      <mvt:do file="g.module_library_utilities" name="g.null" value="SetCookie(g.Output_Cookies, g.cookie_name, g.cookie_value , g.cookiedomain , g.expires, '/', 0 )" />
                      <mvt:do file="g.module_library_utilities" name="g.null" value="OutputCookies( g.Output_Cookies )" />
                  </mvt:if>
              </mvt:if>
              Last edited by AHerb; 08-30-19, 04:39 PM.

              Comment

              Working...
              X