Guest User

Untitled

a guest
Feb 23rd, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. const googleAnalytics = event => {
  2. switch (event.type) {
  3. default:
  4. window.dataLayer.push(event)
  5. }
  6. }
  7.  
  8. const facebook = event => {
  9. switch (event.type) {
  10. case 'pageview':
  11. fbq('track', 'PageView')
  12. case 'completeCheckout':
  13. fbq('track', 'Purchase', {
  14. currency: event.currency
  15. })
  16. }
  17. }
  18.  
  19. const integrations = [googleAnalytics, facebook]
  20.  
  21. export const track = event => {
  22. if (event) {
  23. integrations.forEach(integration => integration(event))
  24. }
  25. }
Add Comment
Please, Sign In to add comment