Comments (9)
Thanks solved
from rack-tracker.
@petervandeput see #110 (comment)
from rack-tracker.
you can set any tracker option dynamically during requests by providing a lambda.
from rack-tracker.
thanks for the quick response, but can you give an example.
When the request is an amp request (mimeType) then it should inject.
from rack-tracker.
not sure about the mime type, but you have access to everything in the rack env.
have a look here:
from rack-tracker.
@petervandeput did that help? mind to share your solution for others?
from rack-tracker.
Not really, problem I'm trying to solve is that when an amp version of the page is request (e.g. by Google) the code is not injected. still haven't figured out how to do
from rack-tracker.
I have no experience with AMP but let's figure this out.
Please refer to this spec as an example: f3d4e65#diff-f961e0b587e363c3a6cd9a6a3a231684
You have full access to anything in the rack env hash, which might look something similar to this:
{
"GATEWAY_INTERFACE"=>"CGI/1.1",
"HTTP_ACCEPT"=>"text/html,application/xhtml+xml",
"HTTP_ACCEPT_ENCODING"=>"gzip",
"HTTP_ACCEPT_LANGUAGE"=>"en-US,en;q=0.8,de;q=0.6",
"HTTP_CACHE_CONTROL"=>"max-age=0",
"HTTP_HOST"=>"localhost:3000",
"HTTP_USER_AGENT"=>"Mozilla/5.0 (Macintosh; Intel Mac OS X)",
"HTTP_VERSION"=>"HTTP/1.1",
"PATH_INFO"=>"/",
"QUERY_STRING"=>"",
"rack.version"=>[1, 3],
"rack.url_scheme"=>"http",
"REMOTE_ADDR"=>"127.0.0.1",
"REMOTE_HOST"=>"localhost",
"REQUEST_METHOD"=>"GET",
"REQUEST_PATH"=>"/"
"REQUEST_URI"=>"http://localhost:3000/",
"SCRIPT_NAME"=>"",
"SERVER_NAME"=>"localhost",
"SERVER_PORT"=>"3000",
"SERVER_PROTOCOL"=>"HTTP/1.1",
"SERVER_SOFTWARE"=>"WEBrick/1.3.1 (Ruby/2.2.1/2015-02-26)",
}
Are you sure the request url contains what you're looking for? or is it maybe the referrer?
So if the env hash is not enough, you should be able to access the controller instance with env["action_controller.instance"]
and ask the request object for further information to decide if you inject the tracker.
from rack-tracker.
@petervandeput do you want to share an example on how you solved it?
This might be helpful for others who try to do similar things.
from rack-tracker.
Related Issues (20)
- No such handler: Facebook pixel (ArgumentError) HOT 3
- How to use outside of controller? HOT 5
- Google Analytics using the beacon transport HOT 1
- Syntax when using rack-tracker for both Google Analytics and Google Ads HOT 4
- Bing tracking HOT 1
- Sending rack-tracker events from "backend" code HOT 3
- Render templates directly for JS responses HOT 3
- Google Tag Manager with turbolinks: true duplicates pageView when using Push HOT 6
- No events being injected into the page HOT 1
- Google Global integration: purchase transaction_id HOT 7
- content security policy HOT 10
- how to set user_id? HOT 1
- How can I use the tracker in a model or service? HOT 3
- Remote form and AJAX request redirects never run events HOT 2
- syntax error, unexpected ':', expecting keyword_end (SyntaxError) HOT 6
- Can not get FacebookPixel to work HOT 1
- Add Support for Reddit Ads Pixel HOT 3
- Update is coming ? Google Analytics 4 GA4 Killed my groove HOT 11
- Can't Override Default google_tag_manager Event
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 rack-tracker.