2

we have Magento 2.1.7ce and would like to add the MailChimp popup to our homepage.

We currently don't have access to the FTP/SSH so we have to do this with the cms pages.

When i add this code to a CMS page:

<script type="text/javascript" src="//s3.amazonaws.com/downloads.mailchimp.com/js/signup-forms/popup/embed.js" data-dojo-config="usePlainJson: true, isDebug: false"></script><script type="text/javascript">require(["mojo/signup-forms/Loader"], function(L) { L.start({"baseUrl":"mc.us7.list-manage.com","uuid":"xxxxxxxxxxxxxxxxxxxxxxxx","lid":"xxxxxxxxxxx"}) })</script>

And access the firebug console sees it's trying to load files from the static files:

"NetworkError: 404 Not Found - https://server.com/static/frontend/Theme/customtheme/nl_NL/mojo/signup-forms/Loader.js

"NetworkError: 404 Not Found - https://server.com/static/frontend/Theme/customtheme/nl_NL/dojo.js"

How can I fix this? Or is it not allowed to use JavaScript in cms pages?

1

Mailchimp uses dojo for managing required modules and dependencies.

Line

require(["mojo/signup-forms/Loader"], function(L) { L.start({"baseUrl":"mc.us7.list-manage.com","uuid":"xxxxxxxxxxxxxxxxxxxxxxxx","lid":"xxxxxxxxxxx"}) })

conflicts with the RequireJS, that is used in Magento.

You can use Mailchimp Embedded forms instead of the Subscriber pop-up and use Modal widget for embedding form into popup

| improve this answer | |
0

I've built the modal popup and it all works.

Structure includes calling a block called newsletter.php which has return 'Dummy Content' in it.

Question is,

I've got the embed form code from my mailchimp account by I don't know how to add that to a block in M2 or should I scrap the block and just add it into the newsletter.phtml file?

I'm a bit confused

| improve this answer | |
0

Magento allow to use JavaScript in cms pages.

I tried your js, the //s3.amazonaws.com/downloads.mailchimp.com/js/signup-forms/popup/embed.js js loaded well.

The problem is lacking dojo.js.

If you don't have access to the ftp/SSH, you could upload the dojo.js to s3.amazonaws.com, then load it like embed.js,

like

<script type="text/javascript" src="//s3.amazonaws.com/the-path-to/dojo.js" > </script>

After you load embed.js, if it still doesn't work, use the develop tool(Chrome is F12) to find the problem. I guess the "mailchimp popup" function need several js files, you doesn't upload and use them completely.

| improve this answer | |
  • Any solution for this fix ? – Learner Nov 22 '17 at 13:28
0

conflicts with the RequireJS, that is used in Magento so that we can use different code try below code which works well

<script type="text/javascript"
        src="//downloads.mailchimp.com/js/signup-forms/popup/unique-methods/embed.js"
        data-dojo-config="usePlainJson: true, isDebug: false"></script>
<script type="text/javascript">
  setTimeout(mailchimp, 2000);
  function mailchimp() {
    window.dojoRequire(["mojo/signup-forms/Loader"], function(L) {
      L.start({
        "baseUrl": "mc.xxx.list-manage.com",
        "uuid": "xxxxx",
        "lid": "xxxxx",
        "uniqueMethods": true
      })
    })
  }
</script> 
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.