James Lewis
James Lewis

Reputation: 303

Vuejs - How to insert JS Tracking Codes like Google Analytics or Adsense

So I am developing a site as a SPA with Vue JS and I have just came across a issue.

I went to insert Adsense's code snippet like i would normally, but Vue complains with the following

So I am now a bit stuck, I have seen a library that will put Adsense in as a component but its a very new/small library and i could not get the thing to work.

I also have a lot of other tracking pixels that will need to go on the site in a similar fashion so I will need to find a way around doing this.

Can anyone lend some advise, thanks.

Upvotes: 3

Views: 2210

Answers (1)

Friendly Genius
Friendly Genius

Reputation: 325

Try modifying the index.html file instead of the *.vue files. The Vue SPA app automatically listens for updates to *.vue files. So pasting the snippet in html file will bypass the compiler checks for undefined variables, etc.

Upvotes: 1

Related Questions