Comments (5)
No worries! Will your <div class="child">
be only child of <div class="parent" ... >
too? In that case you can do:
var form = wrapper.children[0].children[0]
instead of:
var form = wrapper.children[0]
from docs.
Hi @Waleedov!
The following code should work if the <form>
element is the only child of the wrapper <div>
:
<div data-analytics='"My Event Without Properties"'>
<form>
<button type="submit">Send Message</button>
</form>
</div>
<div data-analytics='"My Event",{"props":{"my_property":"some_value"}}'>
<form>
<button type="submit">Send Message</button>
</form>
</div>
<script>
let wrapperElements = document.querySelectorAll('div[data-analytics]')
for (var i = 0; i < wrapperElements.length; i++) {
let wrapper = wrapperElements[i]
var form = wrapper.children[0]
let attributes = wrapper.getAttribute('data-analytics').split(/,(.+)/);
let eventName = JSON.parse(attributes[0])
let eventOptions = JSON.parse(attributes[1] || '{}')
eventOptions.callback = function() { form.submit() }
form.addEventListener('submit', function(event) {
event.preventDefault();
setTimeout(eventOptions.callback, 5000);
plausible(eventName, eventOptions)
})
}
</script>
Hope this helps!
from docs.
Thanks, to be exact, this is the structure:
<div class="parent" data-analytics='"My Event Without Properties"'>
<div class="child">
<form>
<button type="submit">Send Message</button>
</form>
</div>
</div>
Can you please adjust the code? sorry I am very noob in JS.
from docs.
Thank you. Where can I ask for premium support? Someone to check my website, dashboard etc..?
from docs.
hi @Waleedov! you can reach our customer support here
from docs.
Related Issues (20)
- Average visit duration when queried per page reported via API differs from one in UI HOT 1
- Possible to replicate the pricing slider on the "Choose the right subscription tier" docs page? HOT 1
- What's the API to list sites HOT 2
- Docker Secrets support is undocumented HOT 1
- Update instruction removes all collected data HOT 3
- New session HOT 1
- Plausible container is constantly restarting HOT 1
- Auto Height for iframe embed? HOT 1
- Historical data retention?
- Spektrix ecommerce tracking on Plausible Custom Event Sales
- Plausible with Node.js HOT 1
- Question on alternative to proxy approach for JS script HOT 2
- Docker plausible connect with external postgres database HOT 1
- Viewing all custom properties of events while filtering on one custom property HOT 1
- [Question] Reverse proxy issues HOT 1
- Comparsion is only in the graph, missing from all boxes below HOT 1
- self host invite_only - adding a viewer still allows a viewer to create a new website +Add Website HOT 1
- Custom events without having to manually add in console HOT 1
- Modsecurity trigger on text/plain please add description to whitelist Plausible in modsecurity. HOT 1
- Manual width mode does not work HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from docs.