Hello !
If the error message appears, it’s because the Mautic JavaScript API wasn’t loaded properly. Can you check in the network tab of your browser console if everything is loaded ?
I don’t see anything strange in your code here…
Thread Starter
songee
(@songee)
Thank you for lending me a hand, shulard!
I’ve checked the network tab and the only Mautic related JS files that are loaded are generate.js and mautic-form.js.
I’m running an nginx webserver and previously had a problem where loading https://mywebsite.com/mautic/mtc.js resulted in 404 error and I had to load it via https://mywebsite.com/mautic/index.php/mtc.js for it to work.
I made the following changes in the server bock of my nginx configuration file to make it load without the index.php in the link:
location /mautic/ {
try_files $uri $uri/ /mautic/index.php$is_args$args;
location ~ \.php {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.3-fpm.sock;
include /etc/nginx/my_includes/fastcgi_optimize.conf;
}
}
location = /mautic/mtc.js {
expires off;
default_type "application/javascript";
try_files $uri $uri/ /mautic/index.php$is_args$args;
}
location = /mautic/form/generate.js {
expires off;
default_type "application/javascript";
try_files $uri $uri/ /mautic/index.php$is_args$args;
}
I think there may be a problem with the way nginx is configured on my end since I’m executing wpmautic_send() correctly?
Also, the network tab shows that generate.js file is being loaded from the URL https://mywebsite.com/mautic/index.php/form/generate.js?id=6 with the index.php in the link.
-
This reply was modified 5 years, 3 months ago by
songee.
Hello !
The index.php can be a bit annoying in the webserver configuration but must not cause issue on the frontend when loading components. If you can load forms, the tracker can also be loaded.
Can you share an URL where I can take a look directly in the website ? Also what’s the configured Mautic URL in the plugin setting page ? And which option did you chose to load the tracker ?
Thread Starter
songee
(@songee)
Thread Starter
songee
(@songee)
Hi @shulard.
I wonder if there are any news about the issue?
Hello !
Sorry for the late reply, I just took a look and it seems that your webpage fail to load the mtc.js file.
After accepting cookies, I got the following error in the browser console :
Uncaught Error: Error: remote script failed https://polynook.com/mautic/mtc.js - https://polynook.com/wp-content/cache/autoptimize/js/autoptimize_61563aeb45d3843260000b040dd669cc.js: 2
I don’t know how to solve it, the mtc.js file is accessible and valid. Maybe it’s related to some others plugins you use ?