问题
I have a site and I want to take the pageviews for specific urls using google tag manager and datalayer variables.
Example urls
http://www.test.com
http://www.test.com/e-shop
http://www.test.com/contact
I create datalayer variables with home eshop contact
After I set the following trigger using every datalayer variable as custom events
home
eshop
contact
After that what code should I write in tag I have named it Pageviews in order to have this variables in google analytics?
Is there any easier way to make it but again using datalayer?
回答1:
You don't necessarily need a custom dataLayer variable for this. I would do it this way:
Create a new Tag
- Product: Google Analytics
- Tag Type: Universal Analytics
- Configuration:
- Track Type: Page View
- Tracking ID: your Tracking ID
- Fire on:
- Some Pages
In the overlay popping up on step 4, add 3 new triggers as follows
| Name | Variable | Operation | Value |
| Home | Page Path | equals | / |
| E-Shop | Page Path | equals | e-shop |
| Contact | Page Path | equals | contact |
Save and test your new tag in preview mode. This setup will use the event
dataLayer variable behind the scene, which sends a "Page View" event by default.
来源:https://stackoverflow.com/questions/31732017/taking-the-pageviews-of-urls