Complianz not working with Google Maps Api
-
Hey,
I am using Complianz and Google Maps API together which is not working. It seems that Complianz is not targeting the Google Maps API script to change it from the “text” to “Javascript” so the script actually runs.
I have tried everything in Complianz setup and integrations and disabled everything aswell as enabled everything.
As soon as i disable the Plugin itself the Google Maps API work.
I hope someone can help
-
Hi @mranla,
Could you please share the URL of the page where you embedded Google Maps? You can do this privately under ‘the page I need help with’.
Could you also tell me how you embedded the Google Map? Did you use a particular pagebuilder or plugin?
Kind regards,
LeonHi @leonwimmenhoeve,
I can’t share the link unfortunately.
The script is being loaded from the Functions.php file within a if statement that check the given page the user is on. If the user is on the page that require the Google Map the script loads.
The script also has a “True” statement in the end to make sure the script runs in the footer (I tried changing this to false and it didn’t work).
The script also has a “?version=” after the main src part, i also tried to disable that and nothing.
I hope you can still help without the link, i know it’s harder to troubleshoot.
Best regards,
Andreas@mranla Could you try adding the Maps script to the Script Center? Complianz -> Integrations -> Script Center.
You can then disable the Google Maps integration (Complianz -> Integrations -> Services).
Please let me know if that solves the problem.
Regards,
LeonHey @leonwimmenhoeve ,
I just did the following:
1. Commented the line that enqueues the API in the functions.php
2. Went to the Script center and entered
src=” __MYAPI.GOOGLEHERE__&callback=initMap”
3. I disabled the Integration for Google MapsAnd now the script is the last script in the body to get loaded but it still has the “text/plain” type and class “cmplz-script cmplz-script”. It actually has 2x type “text/plain”
So the script still doesn’t work.
Hi @mranla,
Do you have any console errors when trying to activate Google Maps?
It seems you have some experience, you can have a read here to integrate with Complianz with custom implementations: https://complianz.io/developers-guide-for-third-party-integrations/ you can start by wrapping the script with the code below this paragraph;
Javascript: Use cookies placed by Complianz
Let me know if this helps,
regards Aert
Hi @aahulsebos ,
It gives me “Google is not defined” on the site when i have the script enqueued from the functions.php
I will try the method you described and return with an answer.
Thanks for helping.Best regards,
AndreasHi @aahulsebos ,
This didn’t work either. It entered the script on the page but it didn’t load the Google Map.
I am actually more curious to the:
PHP: Block loading of javascript until consent is givenI implemented the Google Maps API in this and it seems to be able to switch the script now compared to before.
Whenever the user has “Allow all” cookies it changed the script to “text/javascript” and if the user has “Only functional” the script type changes to “text/plain”.But… It still doesn’t work. I can visually see the text/plain change to text/javascript so that’s good, but the console error with “Google is not defined” is still there whether or not the type is plain or javascript.
The error points to a code that contains:
“mapTypeId: google.maps.MapTypeId.ROADMAP,”
I can’t really see the issue here so i doubt it’s the real problem lying here since i know i works if i disable the Complianz plugin.I hope you guys can give me some input here.
I appreciate the help alot!Best regards,
AndreasPossibly the issue is that you have two scripts, where one is dependent on the other. For example, if you load an API, like this:
<script src=”api-url”></script>Then load some inline script, or another script:
<script>
….
mapTypeId: google.maps.MapTypeId.ROADMAP
….
</script>Your issue can occur if the second script is not blocked, or if it is loaded in the wrong order.
If you haven’t done so already, please make sure both scripts are blocked, either in the script center or with some code:
add_filter( 'cmplz_known_script_tags', 'cmplz_custom_block_maps' ); function cmplz_custom_block_maps( $tags ) { $tags[] = 'api-url'; $tags[] = 'google.maps.MapTypeId.ROADMAP'; return $tags; }If this is the case and you still get this error it is a dependency problem. The second script is loaded before the api script. You can tell Copmlianz that it should wait for another script like this:
/** * Conditionally add the dependency * $deps['wait-for-this-script'] = 'script-that-should-wait'; */ add_filter( 'cmplz_dependencies', 'cmplz_custom_maps_dependencies' ); function cmplz_custom_maps_dependencies( $tags ) { $tags['api-url'] = 'google.maps.MapTypeId.ROADMAP'; return $tags; }I think the MapTypeId should be fine, but you should of course replace the string ‘api-url’ with the actual Google Maps string javascript resource URL you use.
If you still have issues, please send use your domain at support(at)complianz.io so we can take a look at the live site.
-
This reply was modified 5 years, 11 months ago by
Rogier Lankhorst.
Hej @rogierlankhorst ,
Thanks for the quick reply and in depth reply, i aprreciate it alot.
The last thing actually worked, it was calling the JS gmap.js i use before the API was completely called.
Let’s say i wanted to show the Google Map even when the user only said “Only allow functional”, because the Google Map is actually not for Marketing use.What do i change in the code to be able to this?
Quick note: This was my intention from the beginning but wasn’t working at all either, so that’s why i changed my approach.I hope you can help me.
Cheers and best regards,
AndreasHi @mranla,
You can remove any scripts relating to Google Maps from the script center and disable Google Maps from the integration > services list.
NB. You might not be using Google Maps for marketing purposes. The name of the category is to be understood a bit broader, namely all third-parties that collect data from your website visitors, for different purposes, but not excluding “Marketing”.
In this case, Google will collect data from your users for different purposes.
Hi @aahulsebos ,
That’s the weird part. I have nothing in the script center and i disabled the Google Maps in integration. I also did not enable it in the:
“Select the types of third party services you use on your site.”So there shouldn’t be anything stopping the script from executing even when the user has “Only functional”.
As to the Marketing case, i will check if the Map actually collects any data what so ever, which i think it doesn’t. It is only functional.
Best regards,
AndreasHi @mranla By any chance are you using Advanced Custom Fields on this website? If so, could you disable the ACF integration under Complianz -> Integrations -> Plugins as well? If affects Google Maps as well.
I hope this helps.
Kind regards,
Leon-
This reply was modified 5 years, 11 months ago by
Leon Wimmenhoeve. Reason: typo
Hi @leonwimmenhoeve ,
I didn’t know that and i just tried to disable the plugin in the “Plugin” section of the “Complainz” plugin. It did not work.
It still only works when i click “Accept all”, but i press “Only functional”, the map does not work.
I hope you can help me with this, it somehow seems less problematic than the other issue i had, but it is still not working.
Best regards,
Andreas@mranla It is very hard for us to investigate your problem if we can’t see the issue. Would it be possible to share the URL privately via email? support(at)complianz.io.
Regards,
Leon@leonwimmenhoeve I have now sent you the URL on mail.
-
This reply was modified 5 years, 11 months ago by
The topic ‘Complianz not working with Google Maps Api’ is closed to new replies.